#33716: Async-capable middleware is not async-capable
---------------------------------+--------------------------------------
     Reporter:  abetkin          |                    Owner:  nobody
         Type:  Uncategorized    |                   Status:  new
    Component:  Uncategorized    |                  Version:  4.0
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------
Description changed by abetkin:

Old description:

> 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

New description:

 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:

 [[Image(https://code.djangoproject.com/attachment/ticket/33716/bug.png)]]

 {{{
 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#comment:1>
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/01070180d418fd7b-960440f7-a268-4968-a47f-365a67c403f3-000000%40eu-central-1.amazonses.com.

Reply via email to