jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
364 stars 58 forks source link

Add Async Support #193

Open Archmonger opened 2 years ago

Archmonger commented 2 years ago

Currently, the DownloadView operates as a sync view. It's very possible (and much more efficient) to do everything async.

File reading will have to be done via aiofile in order to not break the ASGI event queue though. After this change, Django versions will need to be limited to 3.1+

Natim commented 1 year ago

Would you be interested to file a PR implementing this?

Archmonger commented 1 year ago

Yes, but my time is spread a bit thin across the projects I currently support. It might take a while for me to get to this.

Archmonger commented 1 year ago

Note: I have an in-progress PR for whitenoise which has an implementation of sending files via async in Django. The implementation in this repo would be heavily similar.

I believe Django supports async iterators within StreamingHttpResponse now. Async support within django-downloadview should be pretty simple to implement especially since I created a Django-compatible async file iterator in that whitenoise PR.