Gremlin Python无法运行事件循环



我正在运行Gremlin Python。首先,我按照这里的说明在我的本地机器上进行了安装,然后我在这里运行了这个网站的代码,但我在这一点上得到了以下错误:

heading('SubgraphStrategy - just Texas airports')
strategy = SubgraphStrategy(vertices=__.has("region","US-TX"), edges=__.hasLabel('route'))
g2 = g.withStrategies(strategy)
verts = g2.V().count().next()
RuntimeError: Cannot run the event loop while another loop is running

我用以下代码验证了我与Gremlin服务器的图形数据库的连接

%%graph_notebook_config
{
"host": "localhost",
"port": 8182,
"ssl": false,
"gremlin": {
"traversal_source": "g"
}
}

我找到了一些解决";RuntimeError:当另一个循环正在运行时无法运行事件循环",就像nest_async,但后来我得到了一个不同的错误。

谢谢

如果您在Jupyter笔记本中使用Gremlin Python,则事件循环将已经在运行。3.5.x和3.6.x Gremlin Python客户端有一个选项,您可以在创建客户端对象时指定该选项,使其能够工作。你所需要做的就是这样的事情:

from gremlin_python.driver.aiohttp.transport import AiohttpTransport
# other common imports not shown
connection = DriverRemoteConnection(endpoint,'g',
transport_factory=lambda:AiohttpTransport(call_from_event_loop=True))
g = traversal().withRemote(connection)

最新更新