Closed JavieHush closed 2 weeks ago
The Neo4J Async lib has an issue leveraging the existing loop but it can use get_event_loop(). I tested both networKx and Neo4J with the following:
def always_get_an_event_loop() -> asyncio.AbstractEventLoop:
try:
**loop = asyncio.get_event_loop()**.
except RuntimeError:
logger.info("Creating a new event loop in main thread.")
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loop
This seems to work for both cases. I can do a quick pull for this.
fixed for all use cases (NX/Neo) in: #221 . thanks for sussing this out @JavieHush
When trying to get a loop, we'll always get an error said
RuntimeError: no running event loop
. The code could run correctly before several commits, however, it somehow got a bug now...The problematic code is as follows
to fix this bug, the code can be modified as follows
This fix could solve issue #214 Plus, I format the code in the project using ruff-format