1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

Fixed #36281 -- Used async-safe write in ASGIHandler.read_body().

Thanks Carlton Gibson for reviews.
This commit is contained in:
신우진
2025-04-08 16:20:37 +09:00
committed by Mariusz Felisiak
parent 9d93e35c20
commit 1fb3f57e81
2 changed files with 73 additions and 1 deletions

View File

@@ -263,7 +263,16 @@ class ASGIHandler(base.BaseHandler):
raise RequestAborted()
# Add a body chunk from the message, if provided.
if "body" in message:
body_file.write(message["body"])
on_disk = getattr(body_file, "_rolled", False)
if on_disk:
async_write = sync_to_async(
body_file.write,
thread_sensitive=False,
)
await async_write(message["body"])
else:
body_file.write(message["body"])
# Quit out if that's the end.
if not message.get("more_body", False):
break