mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #34428 -- Made ASGIStaticFilesHandler adapt response to async iterator.
Bug in 0bd2c0c901.
This commit is contained in:
@@ -103,4 +103,13 @@ class ASGIStaticFilesHandler(StaticFilesHandlerMixin, ASGIHandler):
|
||||
async def get_response_async(self, request):
|
||||
response = await super().get_response_async(request)
|
||||
response._resource_closers.append(request.close)
|
||||
# FileResponse is not async compatible.
|
||||
if response.streaming and not response.is_async:
|
||||
_iterator = response.streaming_content
|
||||
|
||||
async def awrapper():
|
||||
for part in await sync_to_async(list)(_iterator):
|
||||
yield part
|
||||
|
||||
response.streaming_content = awrapper()
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user