mirror of
https://github.com/django/django.git
synced 2025-11-22 20:16:24 +00:00
Refs #36315 -- Used contextlib.closing() in ASGIHandler.handle().
This commit is contained in:
parent
5ef870fbc5
commit
796cf3d325
1 changed files with 53 additions and 53 deletions
|
|
@ -3,7 +3,7 @@ import logging
|
|||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
from contextlib import aclosing
|
||||
from contextlib import aclosing, closing
|
||||
|
||||
from asgiref.sync import ThreadSensitiveContext, sync_to_async
|
||||
|
||||
|
|
@ -174,6 +174,8 @@ class ASGIHandler(base.BaseHandler):
|
|||
body_file = await self.read_body(receive)
|
||||
except RequestAborted:
|
||||
return
|
||||
|
||||
with closing(body_file):
|
||||
# Request is complete and can be served.
|
||||
set_script_prefix(get_script_prefix(scope))
|
||||
await signals.request_started.asend(sender=self.__class__, scope=scope)
|
||||
|
|
@ -232,8 +234,6 @@ class ASGIHandler(base.BaseHandler):
|
|||
else:
|
||||
await sync_to_async(response.close)()
|
||||
|
||||
body_file.close()
|
||||
|
||||
async def listen_for_disconnect(self, receive):
|
||||
"""Listen for disconnect from the client."""
|
||||
message = await receive()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue