#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: <https://code.djangoproject.com/ticket/33738#comment:4>
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/01070181a0e58162-24d074c5-8ff6-4373-9782-43a0f0453b4b-000000%40eu-central-1.amazonses.com.

Reply via email to