#33738: ASGI http.disconnect not handled on requests with body.
-------------------------------------+-------------------------------------
     Reporter:  Carlton Gibson       |                    Owner:  Dennis
                                     |  Chukwunta
         Type:  Bug                  |                   Status:  assigned
    Component:  HTTP handling        |                  Version:  4.0
     Severity:  Normal               |               Resolution:
     Keywords:  ASGI                 |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

 With regard to detecting `http.disconnect`, it looks like there are two
 options.

 First, if we gave `ASGIRequest` a reference to the application `receive`
 queue (via `__init__`) then we could add something like an
 `is_disconnected` method that could see if there was an event message
 pending, and if it were, whether it was a `http.disconnect` method. (I
 don't think the spec allows anything else, since the body messages have
 been consumed prior to instantiating the request.) Views could then call
 this method periodically, or before beginning an expensive process, to
 know to finish up early.

 Second, inside handle we could launch a separate task to `get` on the
 receive queue after creating the `body_file` and listen for the disconnect
 events which we'd then use as notice to cancel the view dispatch. That
 would need some restructuring, since the view dispatch would need wrapping
 in a task (in order to have something to cancel), but I guess would be
 feasible. Proof-of-concept here desirable. 🤔

 I think option 1 if probably simpler.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33738#comment:8>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701865a9f9d6a-969d1085-5e4f-456b-b2cd-d5f9edbbdd17-000000%40eu-central-1.amazonses.com.

Reply via email to