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.
UPDATED 2023-08-29 :
The latest versions of the Gremlin Python client now use AIOHTTP as their transport mechanism. This has very little impact on application programs, but it is an important change to be aware of. The client now has a parameter that can be used upon creation telling it to nest the event loops.