Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[Django] #35592: ASGIHandler fully buffers request before handling it

7 views
Skip to first unread message

Django

unread,
Jul 11, 2024, 7:02:56 AM7/11/24
to django-...@googlegroups.com
#35592: ASGIHandler fully buffers request before handling it
-------------------------------------+-------------------------------------
Reporter: Klaas van Schelven | Type:
| Uncategorized
Status: new | Component:
| Uncategorized
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The `ASGIHandler`
[https://github.com/django/django/blob/86e13843c2ab510fba1de84588efe7fd03555531/django/core/handlers/asgi.py#L170
reads the full request body] before proceeding with actually "doing the
Django thing" (processing the request with a view).

In this aspect the `ASGIHandler` has less support for streaming than the
`WSGIHandler`.

When running Django as a WSGI application, I am able to start reading from
a request (using `request.read(chunk_size)` as it becomes available to my
web server. This enables me to process large requests in a streaming way
(lower latency, support for abort-early). When running Django as an ASGI
application (at least as per the provided `asgi.py`) I am unable to do
this.

This is contrary to my general expectation that things starting with an
'A' should have equal or better support for streaming than things starting
with a 'W'. The following line from the ASGI spec gives credit to that
expectation "ASGI attempts to preserve a simple application interface,
while providing an abstraction that allows for data to be sent and
received at any time"
--
Ticket URL: <https://code.djangoproject.com/ticket/35592>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 11, 2024, 10:53:09 AM7/11/24
to django-...@googlegroups.com
#35592: ASGIHandler fully buffers request before handling it
------------------------------------+--------------------------------------
Reporter: Klaas van Schelven | Owner: (none)
Type: New feature | Status: closed
Component: HTTP handling | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: asgi | 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):

* component: Uncategorized => HTTP handling
* keywords: => asgi
* resolution: => duplicate
* status: new => closed
* type: Uncategorized => New feature

Comment:

Duplicate of #33699. This behaviour is mandated by the ASGI spec. See
[https://code.djangoproject.com/ticket/33699#comment:6 comment:6] for
details.
--
Ticket URL: <https://code.djangoproject.com/ticket/35592#comment:1>

Django

unread,
Jul 11, 2024, 10:53:52 AM7/11/24
to django-...@googlegroups.com
#35592: ASGIHandler fully buffers request before handling it
------------------------------------+--------------------------------------
Reporter: Klaas van Schelven | Owner: (none)
Type: New feature | Status: closed
Component: HTTP handling | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: asgi | 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):

* cc: Carlton Gibson (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/35592#comment:2>
Reply all
Reply to author
Forward
0 new messages