I am trying to use fastapi with gremlin-python. That library uses tornado as transport for connecting to gremlin server, especially it uses httpclient and websockets along with tornado's ioloop.
Problem is that python prohibits nested event loops and I get runtime errors: https://pastebin.com/mcFhuKks Currently as workaround I use nest_asyncio, but that's a very unreliable solution.
Since previously I saw several issues here regarding asyncio loops (though mostly regarding aiohttp), I am curious if there is some simple way to solve that problem (e.g. somehow reuse parent event-loop).
Also I'd like to notice that gremlin-python DB connection constructor supports passing custom transport factory (instead of default), and I tried to use something like asyncio.get_event_loop()
and asyncio.run_until_complete()
instead of tornado's alternatives, but with no luck.
Hence I'm here for any ideas or probable solutions.
- FastAPI Version: ==0.61.1
- Python version: python:3.8-slim
Just a bad architecture of gremlin library. Created synchronous transport factory using websocket-client, now works fine.