django-downloadview icon indicating copy to clipboard operation
django-downloadview copied to clipboard

Add Async Support

Open Archmonger opened this issue 3 years ago • 3 comments

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+

Archmonger avatar Feb 12 '22 04:02 Archmonger

Would you be interested to file a PR implementing this?

Natim avatar Aug 04 '22 14:08 Natim

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 avatar Aug 04 '22 17:08 Archmonger

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.

Archmonger avatar Jul 05 '23 10:07 Archmonger