-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation regarding "Attached to a different loop" error #688
Comments
FYI thanks to the above issues I think I figured out my own variant of this issues. It seems you can hit the same error when using Gunicorn with Uvicorn workers and the --preload/preload_app option. I just figured I'd add that here so the eventual documentation can inclued it. |
Thanks @rnd42 for raising this! Is the workaround the same in this case? |
In my case I was trying to move the database setup into an on startup function which just had more and more knock on effects... Had to move creating the FastAPIUsers instance into on startup so the database would exist, then had to move the router generation because the FastAPIUsers didn't exist yet, etc, etc... I finally stopped to do some research, found these issues, reverted my changes and just disabled the Gunicorn preload option and everything just worked. |
Ok, it doesn't surprise me that Actually, I feel that all this happens because Motor, contrary to most database drivers, doesn't have a "connect"/"disconnect" mechanism: it directly wires the I/O loop at initialization. |
I'm facing similar issues too with gunicorn. I don't use --preload option in gunicorn but I'm still getting "Attached to a different loop" error. In my case this is what I'm doing:
|
@scherzocrk Could you start a discussion and share with us your |
Just create a discussion here: #711 |
Since Closing this for now, but feel free to leave a message below if you encounter the problem in |
Following discussion #663 and issue #679, we should add documentation regarding the "Attached to a different loop" error, since it's quite common, especially with Motor.
The text was updated successfully, but these errors were encountered: