Gremlin Python 无法运行事件循环

Aur*_*eon 2 python graph gremlin graph-notebook

我正在运行 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
Run Code Online (Sandbox Code Playgroud)

我使用以下代码验证了与 Gremlin Server 的图形数据库的连接

%%graph_notebook_config
{
  "host": "localhost",
  "port": 8182,
  "ssl": false,
  "gremlin": {
    "traversal_source": "g"
  }
}
Run Code Online (Sandbox Code Playgroud)

我找到了一些“RuntimeError:在另一个循环运行时无法运行事件循环”的解决方案,例如 Nest_async 但后来我收到了不同的错误。

谢谢

Kel*_*nce 6

如果您使用的是 Gremlin Python,则在 Jupyter 笔记本中,事件循环已经在运行。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)

Run Code Online (Sandbox Code Playgroud)