The TinkerPop documentation describes GLV for Python. However, the examples presented in there are built around synchronous code. There is the aiogremlin library that was desingned to enable use of Gremlin in Python's asyncio code. Unfortunately, the project seem to be discontinued.
Does the official GLV support the asyncio or is there a way to use Gremlin in asynchronous Python applications?
I noticed that this question has sat unanswered so here goes...
The Gremlin Python client today uses Tornado. That may change in the future to just use aiohttp. Getting the event loops to play nicely together can be tricky. The easiest way I have found is to use the nest-asyncio library. With that installed you can write something like this. I don't show the g
being created but this code assumes the connection to the server has been made and that g
is the Graph Traversal Source.
import nest_asyncio
nest_asyncio.apply()
async def count_airports():
c = g.V().hasLabel('airport').count().next()
print(c)
async def run_tests(g):
await count_airports()
return
asyncio.run(run_tests(g))
As you mentioned the other option is to use something like aiogremlin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With