Python Async Gremlin

289 views
Skip to first unread message

jd...@dealersocket.com

unread,
Aug 29, 2018, 6:19:58 PM8/29/18
to Gremlin-users
Hello all,

I am trying to understand what the different models for talking to Gremlin from Python are. As far as I understand there is:

gremlinpython
aiogremlin
goblin

It did not seem like gremlinpython supported async out of the box. I have tried aiogremlin and goblin but have not had much luck. I am new to async\await in Python. Here is some example code I am trying in aiogremlin with python 3.6.4:

from aiogremlin import DriverRemoteConnection
from aiogremlin import Graph
import asyncio
import aiogremlin

result = {}

async def ListVertices():
   async with await DriverRemoteConnection.open('ws://cluster.endpoint:8182/gremlin', 'g') as remote_connection:
       g = Graph().traversal().withRemote(remote_connection)
       print(await g.V().toList())

def Test():
   loop = asyncio.get_event_loop()
   loop.run_until_complete(ListVertices())
   loop.close()

if __name__ == "__main__":
   Test()

which seems to be in line with the docs. After getting

TypeError: Inheritance a class <class 'aiohttp.http_writer.URL'> from URL is forbidden

I installed a compatible version of yarl with pip install "yarl<1.2"

However, now I get this error regardless of the complexity of the traversal I supply:

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    Test()
  File "test.py", line 15, in Test
    loop.run_until_complete(ListVertices())
  File "C:\Users\jdey\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 467, in run_until_complete
    return future.result()
  File "test.py", line 11, in ListVertices
    print(await g.V().toList())
  File "C:\git\database.neptune.sso.salesforce.bulkimporter\lib\site-packages\aiogremlin\process\graph_traversal.py", line 26, in toList
    async for result in self:
  File "C:\git\database.neptune.sso.salesforce.bulkimporter\lib\site-packages\aiogremlin\process\graph_traversal.py", line 18, in __anext__
    object = self.last_traverser.object
AttributeError: 'str' object has no attribute 'object'

Any pointers down this path would be appreciated, as I am trying to create a bulk load of vertices and edges into Neptune and async appears to be the way forward.
Message has been deleted

David Brown

unread,
Aug 30, 2018, 10:53:06 AM8/30/18
to Gremlin-users
Sorry, I am behind on release and maintenance of these libraries. Please try installing aiogremlin from github, update to the latest version of aiohttp, and install the gremlinpython version that corresponds to the tinkerpop release supported by your provider. If you still have problems, I will look into this more closely.
Reply all
Reply to author
Forward
0 new messages