Closed FrancescoSaverioZuppichini closed 1 year ago
Hello and thanks for reaching out. What version of the driver are you using?
Please try creating the driver wrapper (and with it the driver) inside the async main
and let me know if this fixes it. In the meantime I'll try to reproduce the error.
...
async def main():
db_handler = AsyncGraphDBHandler()
...
if __name__ == "__main__":
asyncio.run(main())
This issue reminds me a lot of https://github.com/neo4j/neo4j-python-driver/issues/868 and I thought I fixed it :thinking:
Managed to reproduce it using Python 3.7.
It is indeed the same issue as the one I linked in the previous comment and it does not come from within the driver but how asynio implements synchronization primitives. Until Python 3.9 they use get_event_loop
which creates a new event loop if there is no running loop. So there are a few options forward:
AsyncGraphDBHandler
creation into the async main, which postpones creation of the async synchronization primitives until there is an event loop running.I will close the issue as it doesn't appear to be a bug in the driver. Please feel free to keep commenting if you have further questions.
Managed to reproduce it using Python 3.7.
It is indeed the same issue as the one I linked in the previous comment and it does not come from within the driver but how asynio implements synchronization primitives. Until Python 3.9 they use
get_event_loop
which creates a new event loop if there is no running loop. So there are a few options forward:
- Move the
AsyncGraphDBHandler
creation into the async main, which postpones creation of the async synchronization primitives until there is an event loop running.- Update your Python to 3.10 or newer where asyncio changed the implementation of synchronization primitives to lazily get the event loop when needed and not on initialization. [document removal of] the deprecated 'loop' parameter asyncio API in 3.10Â python/cpython#86558
Thank a lot. Need to check (not at my home pc) but I think I was using python 3.9. I will try with python 3.10 and let you know
Hi there 👋
So I am trying to read files in a batch way and creating records in neo4j
Where my
aparse_eml
opens a file and does some processing to obtain a dataclass
Email
, myAsyncGraphDBHandler
I am getting this error
I think they are running in two different event loops
Since I am here, is there a way to create all the persons concurrently and efficiently, I've tried different things but none of them works.
Thanks a lot
Fra