whitenoise icon indicating copy to clipboard operation
whitenoise copied to clipboard

Upgrade to Django 4.2 raises new warning

Open stumpylog opened this issue 2 years ago • 10 comments
trafficstars

Python Version

3.11.5

Django Version

4.2.5

Package Version

6.5.0

Description

After upgrading a project from Django 4.1.9 to Django 4.2.5, there is a new warning in my application logs:

django/http/response.py:518: Warning: StreamingHttpResponse must consume synchronous iterators in order to serve them asynchronously. Use an asynchronous iterator instead.

After some work and adding some patching, the response in this case is a WhiteNoiseFileResponse. As far as I can tell, everything works correctly, but it would be nice to not have this warning, without silencing it myself.

stumpylog avatar Sep 29 '23 16:09 stumpylog

Is your project public, or do you have some minimal code to reproduce the issue?

bcail avatar Oct 18 '23 21:10 bcail

https://github.com/paperless-ngx/paperless-ngx. dev has upgraded to 4.2. The warning occurs when loading a page. At least it only appears once.

stumpylog avatar Oct 18 '23 21:10 stumpylog

Are you serving your app with uvicorn?

bcail avatar Oct 19 '23 20:10 bcail

gunicorn, though uvicorn is also installed. Sounds like you have an idea then maybe?

stumpylog avatar Oct 19 '23 20:10 stumpylog

uvicorn is for ASGI (async) processing. whitenoise doesn't seem to be supported on ASGI yet: see https://github.com/evansd/whitenoise/pull/359.

bcail avatar Oct 19 '23 20:10 bcail

Ah, that would do it. Thanks!

stumpylog avatar Oct 19 '23 21:10 stumpylog

You're welcome. I guess we could close this issue?

bcail avatar Oct 20 '23 12:10 bcail

It might be better to remain open, linked to be closed with #359, if it can ever merge. Others will probably be seeing it soon enough as they upgrade.

stumpylog avatar Oct 20 '23 20:10 stumpylog

I understand that WhiteNoise does not yet support ASGI, but I would like to better understand whether this warning is critical (this will break something or severely impact performance) or if it's minor.

I'm seeing guides that both recommend WhiteNoise and recommend running with ASGI (e.g., this guide from Render). Is this a reasonable default for a new application?

jayqi avatar Jul 18 '24 02:07 jayqi