#33716: async middleware can be a regular function too
-------------------------------+--------------------------------------
     Reporter:  abetkin        |                    Owner:  nobody
         Type:  Bug            |                   Status:  closed
    Component:  Uncategorized  |                  Version:  4.0
     Severity:  Normal         |               Resolution:  invalid
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 You're not following the guidance in the
 [https://docs.djangoproject.com/en/4.0/topics/http/middleware
 /#asynchronous-support Asynchronous support section of the Middle topic
 doc].

 Specifically:

 > The returned callable must match the sync or async nature of the
 get_response method. If you have an asynchronous get_response, you must
 return a coroutine function (async def).

 You're returning a synchronous callable in **both** cases.

 See the example of a `@sync_and_async_middleware` given there. Note the
 use of `asyncio.iscoroutinefunction(get_response)` to determine what kind
 of callable to return.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33716#comment:14>
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/01070180d5e2aaba-f9df60d4-c74b-41f4-9ae5-f1f46d132bf7-000000%40eu-central-1.amazonses.com.

Reply via email to