Opened 21 months ago
Last modified 21 months ago
#34428 closed Bug
ASGIStaticFilesHandler raises warning. — at Initial Version
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
#33735 added async support to StreamingHttpResponse for Django 4.2.
With Django 4.2rc1 and Daphne, ` 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.