-
Notifications
You must be signed in to change notification settings - Fork 16
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
Async view raises SynchronousOnlyOperation
when also logged into Django admin
#343
Comments
Hello, It looks to me as if you were using the ASGI app with the synchronous jwt middleware. Could you please verify that this is the case? |
@KundaPanda We are using |
Okay so that seems in order. Are you running the app with an ASGI-capable server as well (daphne, uvicorn, hypercorn)? This seems like the second most likely cause (i.e. with the runserver command or gunicorn). |
We've encountered the issue with runserver and runserver_plus Haven't deployed with Async seems to work though. I tested an API with |
That explains it then. You need a proper ASGI server to send ASGI requests -- runserver and runserver_plus both serve WSGI only. Internally this seems to work for you because Django creates a new loop for every incoming request. So you can have async views, but they are not actually running asynchronously. This also means that all Django middleware runs synchronously when processing requests. I will try to look into this and implement own asyncio loop creation in the middleware, but I do not consider this a bug/issue but rather a nice-to-have feature for debugging with runserver. |
If you use channels runserver would be asgi so you can just add channels as dev requirement.. |
Tested with uvicorn. Same error.
|
i.e., when you have the
sessionid
cookie.The workaround is to log out of admin, or delete the
sessionid
cookie.The text was updated successfully, but these errors were encountered: