evansd / whitenoise

Radically simplified static file serving for Python web apps
https://whitenoise.readthedocs.io
MIT License
2.51k stars 148 forks source link

Upgrade to Django 4.2 raises new warning #531

Open stumpylog opened 11 months ago

stumpylog commented 11 months ago

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.

bcail commented 10 months ago

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

stumpylog commented 10 months ago

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.

bcail commented 10 months ago

Are you serving your app with uvicorn?

stumpylog commented 10 months ago

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

bcail commented 10 months ago

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

stumpylog commented 10 months ago

Ah, that would do it. Thanks!

bcail commented 10 months ago

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

stumpylog commented 10 months ago

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.

jayqi commented 1 month ago

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?