You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When trying to insert a new document into the MongoDB an error is thrown.
RuntimeError: There is no current event loop in thread 'AnyIO worker thread'
More Details
...
File "/Users/ccauet/my_project/./mwe.py", line 25, in ingest_data
data_dump.create()
File "/Users/ccauet/my_project/.venv/lib/python3.10/site-packages/beanie/sync/odm/documents.py", line 241, in create
return self.insert(session=session)
File "/Users/ccauet/my_project/.venv/lib/python3.10/site-packages/beanie/sync/odm/actions.py", line 190, in wrapper
ActionRegistry.run_actions(
File "/Users/ccauet/my_project/.venv/lib/python3.10/site-packages/beanie/sync/odm/actions.py", line 111, in run_actions
asyncio.gather(*coros)
File "/Users/ccauet/.pyenv/versions/3.10.4/lib/python3.10/asyncio/tasks.py", line 715, in gather
loop = events._get_event_loop()
File "/Users/ccauet/.pyenv/versions/3.10.4/lib/python3.10/asyncio/events.py", line 656, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'AnyIO worker thread'.
To Reproduce
(Spin up a local test MongoDB with docker run -it -p "27017:27017" mongo)
Expected behavior
I would except the document inserted and no problem due to async stuff.
Additional context
I'm pretty sure it has something to do with FastAPI or even Starlette underneath, but it only starts happing after adding the .create() step. So, somehow I'm opening this issue to get some understanding what happens and maybe where to look next.
The text was updated successfully, but these errors were encountered:
Describe the bug
When trying to insert a new document into the MongoDB an error is thrown.
More Details
To Reproduce
(Spin up a local test MongoDB with
docker run -it -p "27017:27017" mongo
)This is a MWE
Send some example data
deps
Expected behavior
I would except the document inserted and no problem due to async stuff.
Additional context
I'm pretty sure it has something to do with FastAPI or even Starlette underneath, but it only starts happing after adding the
.create()
step. So, somehow I'm opening this issue to get some understanding what happens and maybe where to look next.The text was updated successfully, but these errors were encountered: