#33716: Async-capable middleware is not async-capable
-------------------------------------------+------------------------
Reporter: abetkin | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.0
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
All the standard django middleware is marked as async-capable. As I
understand that means that sync_to_async adapters will not be used if no
other middleware is present.
However, if you call an endpoint that is handled by an async view, somehow
the adapters are still used, and middleware is executed in a separate
thread.
Moreover, if you add your custom middleware that is async_capable than it
tries not to use adapters, and quickly fails:
{{{
AttributeError: 'coroutine' object has no attribute 'get'
}}}
In this example this was XFrameOptionsMiddleware that failed
Github project illustrating this: https://github.com/pwtail/django_bug
--
Ticket URL: <https://code.djangoproject.com/ticket/33716>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070180d41707da-a3e982a5-d4fa-4235-b550-f92dc3710464-000000%40eu-central-1.amazonses.com.