#33745 closed Bug (wontfix)
There is no easy way to turn off sync_to_async and async_to_sync adapters
Reported by: | abetkin | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 4.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hi! I have a setup that is deployed with nginx unit (https://unit.nginx.org)
I have 1 asgi and 1 wsgi application, namely for my sync and async endpoints. All my code runs natively, there is no need to adapt my code with sync_to_async-like stuff.
If an async endpoint somehow (by mistake) gets routed to the wsgi application, it is AN ERROR for me. Because it should have been routed to the asgi app. However, django will silently adapt it and run in a separate thread.
The same happens if a sync endpoint is dispatched to the asgi application. Again, I want that to be an error!
I haven't found any easy way to turn this behavior off or even to check that this is happening, to log it somewhere. I think this is wrong.
Change History (6)
comment:1 by , 2 years ago
Description: | modified (diff) |
---|
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
comment:3 by , 2 years ago
Description: | modified (diff) |
---|
comment:4 by , 2 years ago
Description: | modified (diff) |
---|
comment:5 by , 2 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:6 by , 2 years ago
Thank you, Carlton!
Actually the thing that I missed is that you can tell from request whether it is ASGIReguest or not. And thanks for the code snippet: I was using the resolver too, but my code was less elegant
This would be a good candidate for a custom system check.
There are a number of existing URL checks you can use as an example but, the essential idea would be to check the
callback
of each routed URL:Hopefully that gets you going. Please see TicketClosingReasons/UseSupportChannels if you need more assistance.