#34428: ASGIStaticFilesHandler raises warning.
-------------------------------------+-------------------------------------
Reporter: Carlton Gibson | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Carlton Gibson:
Old description:
> #33735 added async support to `StreamingHttpResponse` for Django 4.2.
>
> With Django 4.2rc1 and Daphne, `StreamingHttpResponse` 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.
New description:
#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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:3>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018704fd8a6b-b5309124-e503-4963-b45c-cf5a75ae3b69-000000%40eu-central-1.amazonses.com.