Skip to content

Commit

Permalink
reorder body_file.close()
Browse files Browse the repository at this point in the history
  • Loading branch information
jthorniley committed Jan 24, 2024
1 parent dbdd78c commit f3363ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/core/handlers/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,15 @@ async def process_request(request, send):
except asyncio.CancelledError:
# Task re-raised the CancelledError as expected.
pass
body_file.close()

try:
response = get_response_task.result()
await sync_to_async(response.close)()
except asyncio.CancelledError:
await signals.request_finished.asend(sender=self.__class__)

body_file.close()

async def listen_for_disconnect(self, receive):
"""Listen for disconnect from the client."""
message = await receive()
Expand Down

0 comments on commit f3363ec

Please sign in to comment.