Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-04-03 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
-+-
 Reporter:  Carlton Gibson   |Owner:  Dennis
 |  Chukwunta
 Type:  New feature  |   Status:  closed
Component:  HTTP handling|  Version:  4.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  ASGI | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"1d1ddffc27cd55c011298cd09bfa4de3fa73cf7a" 1d1ddffc]:
 {{{
 #!CommitTicketReference repository=""
 revision="1d1ddffc27cd55c011298cd09bfa4de3fa73cf7a"
 Fixed #33738 -- Allowed handling ASGI http.disconnect in long-lived
 requests.
 }}}

-- 
Ticket URL: 
Django 
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/01070187485846da-7a1db9df-aec0-44a8-8bf7-618183193105-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-04-03 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
-+-
 Reporter:  Carlton Gibson   |Owner:  Dennis
 |  Chukwunta
 Type:  New feature  |   Status:  assigned
Component:  HTTP handling|  Version:  4.0
 Severity:  Normal   |   Resolution:
 Keywords:  ASGI | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  1 => 0
 * type:  Bug => New feature
 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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/010701874700f329-d272095f-607a-43e0-a803-80dfb645a92f-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-03-29 Thread Django
#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:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
Ticket URL: 
Django 
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/0107018730b0365c-84a14012-2e16-4b3e-8259-a6727e12f3e5-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-03-29 Thread Django
#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:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * needs_better_patch:  1 => 0


Comment:

 OK, I think this is close. Maybe extra eyes would be good on it.

 With the patch we're able to handle the `http.disconnnect` if it comes in
 before the view returns.

-- 
Ticket URL: 
Django 
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/010701872dbbf717-d06f22d7-1743-4997-9eea-ce38776cc7d8-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-02-28 Thread Django
#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:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * needs_better_patch:  0 => 1
 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/16603 PR]

-- 
Ticket URL: 
Django 
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/0107018697309105-6d51f3ba-cf48-4d6f-9741-fdb61dac426a-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-02-16 Thread Django
#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: 
Django 
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-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2023-02-08 Thread Django
#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
-+-
Changes (by Dennis Chukwunta):

 * owner:  nobody => Dennis Chukwunta
 * status:  new => assigned


-- 
Ticket URL: 
Django 
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/0107018634dd27fa-411cf631-111a-4d4e-a664-591e20435fd0-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-09-24 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  Bug |   Status:  new
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 Jeremy Lainé):

 Hi Carlton, I'm not sure if the description of this bug is 100% accurate.
 From what I can see, `http.disconnect` is indeed only handled while
 receiving the body, so we're not going to handle this event once the
 (potentially empty) body is fully received. Adding `"more_body": False` to
 your proposed test makes it pass.

 I had a look for how Starlette handles `http.disconnect`, and from what I
 understand the pattern seems to rely on `anyio.create_taskgroup()` to tear
 down request processing if an `http.disconnect` is received.

-- 
Ticket URL: 
Django 
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/010701836f61c055-6dd12a7b-d165-446c-95c3-369a8210900c-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-06-28 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  Bug |   Status:  new
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):

 Hi Rahul.

 > ... if we perform a loop only while receiving the message and break it
 after X interval of time...

 This won't work I'm afraid. We still need to be able to handle the
 incoming `http.disconnect` at any time.

 It's not 100% straightforward but something **like** Channels'
 `await_many_dispatch()` will be needed. See
 
[https://github.com/django/channels/blob/ae60a7d86f3655a1cc35cd9198e61fe5dcc5d1a1/channels/consumer.py#L56-L62
 the usage here]: it's able to route multiple messages.
 (I don't think the example there is 100% properly handling the disconnect,
 as a kind of interrupt there either, since the dispatch task will only
 process one message at a time, where we're looking to handle a disconnect
 whilst processing a long-running request… 樂)

-- 
Ticket URL: 
Django 
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/01070181a9211192-14b4a726-3dc2-4083-9053-527246239424-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-06-26 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  Bug |   Status:  new
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 rahul negi):

 Replying to [ticket:33738 Carlton Gibson]:

 > {{{
 > async def read_body(self, receive):
 > """Reads an HTTP body from an ASGI connection."""
 > # Use the tempfile that auto rolls-over to a disk file as it
 fills up.
 > body_file = tempfile.SpooledTemporaryFile(
 > max_size=settings.FILE_UPLOAD_MAX_MEMORY_SIZE, mode="w+b"
 > )
 > while True:
 > message = await receive()
 > if message["type"] == "http.disconnect":# This is the
 only place `http.disconnect` is handled.
 > body_file.close()
 > # Early client disconnect.
 > raise RequestAborted()
 > # Add a body chunk from the message, if provided.
 > if "body" in message:
 > body_file.write(message["body"])
 > # Quit out if that's the end.
 > if not message.get("more_body", False):
 > break
 > body_file.seek(0)
 > return body_file
 > }}}
 >

 I'm following this ticket for some days and trying to understand the code
 base learned more about the asynchronous processes and long-polling,
 IDK this is a solution or not,

 if we perform a loop only while receiving the message and break it after X
 interval of time like

 {{{

   while True:
   message = await receive()
   message_queue.append(message)
   if time_waited == X :
   break

 }}}



 and do store it in a queue and then perform a loop on the queue data to
 read the message?

 Please correct me if I'm wrong or if this sounds immature,

 thanks

-- 
Ticket URL: 
Django 
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/01070181a0e58162-24d074c5-8ff6-4373-9782-43a0f0453b4b-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-05-24 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  Bug |   Status:  new
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
+
Changes (by Mariusz Felisiak):

 * type:  New feature => Bug


-- 
Ticket URL: 
Django 
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/01070180f52fe245-10e00506-82f3-41d1-83cf-f8a86e8ddd00-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-05-24 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  New feature |   Status:  new
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):

 > Don't you think it's a bug? 樂

 I had it down as such, but it's never worked, and once I started thinking
 about the **fix** I thought it's probably a non-minor adjustment so...
 (But happy if you want to re-classify :)

-- 
Ticket URL: 
Django 
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/01070180f52eeb05-20fffb4e-77ed-419b-9799-913a0dcc84cc-00%40eu-central-1.amazonses.com.


Re: [Django] #33738: ASGI http.disconnect not handled on requests with body.

2022-05-24 Thread Django
#33738: ASGI http.disconnect not handled on requests with body.
+
 Reporter:  Carlton Gibson  |Owner:  nobody
 Type:  New feature |   Status:  new
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
+
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 Thanks! Don't you think it's a bug? 樂

-- 
Ticket URL: 
Django 
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/01070180f5200c1e-577a477e-569b-4000-ba0d-8df5d8cf8ffd-00%40eu-central-1.amazonses.com.