summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
author신우진 <zebra0345@naver.com>2025-04-08 16:20:37 +0900
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-05-04 14:53:08 +0200
commit1fb3f57e81239a75eb8f873b392e11534c041fdc (patch)
tree6a679645abc2c2962da773a75b081b5c64c2adc3 /django/core
parent9d93e35c207a001de1aa9ca9165bdec824da9021 (diff)
Fixed #36281 -- Used async-safe write in ASGIHandler.read_body().
Thanks Carlton Gibson for reviews.
Diffstat (limited to 'django/core')
-rw-r--r--django/core/handlers/asgi.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/core/handlers/asgi.py b/django/core/handlers/asgi.py
index b57bec90d0..0d305c9a87 100644
--- a/django/core/handlers/asgi.py
+++ b/django/core/handlers/asgi.py
@@ -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