Open ghost opened 2 years ago
Hello, Thanks for submitting the issue.
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 AsyncStatusHandlingGraphQLView
with AsyncJSONWebTokenMiddleware
@KundaPanda We are using
AsyncStatusHandlingGraphQLView
withAsyncJSONWebTokenMiddleware
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 uvicorn
yet.
Async seems to work though. I tested an API with asyncio.sleep(10)
and hit it in 2 tabs.
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.
CMD [ "uvicorn", "mysite.asgi:application", "--host=0.0.0.0", "--port=8000", "--reload" ]
i.e., when you have the
sessionid
cookie.The workaround is to log out of admin, or delete the
sessionid
cookie.