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.
* Attachment "bug.png" added.
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>
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:
>
> [[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
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:
[[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:2>
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
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:
>
> [[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
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:
[[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
Is reproduced in thae main branch and in 4.0
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33716#comment:3>
* status: new => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/33716#comment:4>
* severity: Release blocker => Normal
--
Ticket URL: <https://code.djangoproject.com/ticket/33716#comment:5>