Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 2afe301

Browse files
committed
Expand comment.
1 parent d54f1f5 commit 2afe301

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

synapse/http/server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,11 @@ def resumeProducing(self) -> None:
544544
while not self._paused:
545545
# Get the next chunk and write it to the request.
546546
#
547-
# The output of the JSON encoder is coalesced until min_chunk_size is
548-
# reached. (This is because JSON encoders produce a very small output
549-
# per iteration.)
547+
# The output of the JSON encoder is buffered and coalesced until
548+
# min_chunk_size is reached. This is because JSON encoders produce
549+
# very small output per iteration and the Request object converts
550+
# each call to write() to a separate chunk. Without this there would
551+
# be an explosion in bytes written (e.g. b"{" becoming "1\r\n{\r\n").
550552
#
551553
# Note that buffer stores a list of bytes (instead of appending to
552554
# bytes) to hopefully avoid many allocations.

0 commit comments

Comments
 (0)