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.
--
Ticket URL: <https://code.djangoproject.com/ticket/34428>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/16670 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:1>
Old 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.
New 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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:2>
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>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"02c356f2f3945b8075735d485c3cf48cad991011" 02c356f]:
{{{
#!CommitTicketReference repository=""
revision="02c356f2f3945b8075735d485c3cf48cad991011"
Fixed #34428 -- Made ASGIStaticFilesHandler adapt response to async
iterator.
Bug in 0bd2c0c9015b53c41394a1c0989afbfd94dc2830.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"ae824eceb1ddcaef336677bf9a6e704097cd2309" ae824ece]:
{{{
#!CommitTicketReference repository=""
revision="ae824eceb1ddcaef336677bf9a6e704097cd2309"
[4.2.x] Fixed #34428 -- Made ASGIStaticFilesHandler adapt response to
async iterator.
Bug in 0bd2c0c9015b53c41394a1c0989afbfd94dc2830.
Backport of 02c356f2f3945b8075735d485c3cf48cad991011 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34428#comment:6>