-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Considering ASGI. #179
Comments
Hi Tom, thanks for raising this. Yes, I'd definitely be interested in supporting native ASGI in WhiteNoise. My hope is that it won't actually involve a lot of extra code. Fundamentally, WhiteNoise takes a request path, HTTP method, and headers and returns a status code, response headers, and an open file handle. There's a bit of adaptor code to get this to work with the WSGI and Django middleware specs. So hopefully the ASGI adaptor code will be equally small, but I haven't looked into this in detail yet. I don't know exactly when I'll get time to look at this (the WhiteNoise 4.0 release is already massively behind due to work and family commitments) but very happy to review patches or discuss options. |
I've put together #181, to demonstrate the scope of changes. The most obvious problem would be that using |
In version 5.0 python 2.7 support is dropped so is this a option again? |
Yes, absolutely. It's "just" a case of finding the time. |
@evansd see my comment about possibly moving this project to JazzBand to get the community more involved: |
Okay, I'm going to punt this one out there.
Andrew Godwin's latest work on the ASGI spec, means that there really is now an asyncio-based interface for Python webservers.
I'm planning to shortly be releasing a new release of
uvicorn
, at which point there will be two production-ready ASGI servers. (We already havedaphne
available.)I'll also be releasing a new version of
apistar
which will present either WSGI or ASGI interfaces, so there will be at least two ASGI web application frameworks. (We already have Django Channels)I already use
whitenoise
for serving static files withapistar
, but it's not ideal under ASGI, because we necessarily need to run whitenoise behind as WSGI-to-ASGI adapter, which means that:send_file
. (This isn't currently addressed in the ASGI spec, so that's more complicated to address.)This may well be premature, given the early nature of ASGI, but I'm wondering if you'd consider whitenoise-as-an-ASGI-middleware. If we use sync file operations on load, then I think ASGI support could be addressed with...
WhiteNoise
subclass,ASGIWhiteNoise
that overrides__call__
, andserve
.get_response
and file iteration in the asyncio case, to use something like aiofiles.sendfiles
extension to ASGI might look.I'll likely be tackling some of this as part of my work on apistar, but figured I'd also raise this here just to get an idea of if you'd be interested in seeing ASGI supported directly in whitenoise?
The text was updated successfully, but these errors were encountered: