#34428 closed Bug (fixed)
ASGIStaticFilesHandler raises warning.
Reported by: | Carlton Gibson | Owned by: | Carlton Gibson |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 4.2 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
#33735 added async support to StreamingHttpResponse
for Django 4.2.
With Django 4.2rc1 and Daphne, ASGIStaticFilesHandler
raises a warning about the incorrect iterator type being used:
http/response.py:534: Warning: StreamingHttpResponse must consume synchronous iterators in order to serve them asynchronously. Use an asynchronous iterator instead.
This is because FileResponse
is not async compatible (nor is that likely, since neither is open()
).
A new project with:
INSTALLED_APPS = [ "daphne", ... ] ASGI_APPLICATION = "project.asgi.application"
runserver
, and then visit any page serving static files such as /admin/
.
The fix is to have ASGIStaticFilesHandler
adapt the iterator in the same way StreamingHttpResponse
does.
Change History (6)
comment:1 by , 20 months ago
Has patch: | set |
---|
comment:2 by , 20 months ago
Description: | modified (diff) |
---|
comment:3 by , 20 months ago
Description: | modified (diff) |
---|
comment:4 by , 20 months ago
Triage Stage: | Unreviewed → Accepted |
---|
PR