From 5283a6e47e7048054c70aee58528323b082f80f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Oct 2025 19:29:32 +0000 Subject: [PATCH 1/2] Initial plan From 160361e42c54d8fc1cb4e326def669f470ce0e81 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Oct 2025 19:37:50 +0000 Subject: [PATCH 2/2] Update memory.rst to correctly document max_queue in threading implementation Co-authored-by: aaugustin <788910+aaugustin@users.noreply.github.com> --- docs/topics/memory.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/topics/memory.rst b/docs/topics/memory.rst index 61b1113e2..d39277540 100644 --- a/docs/topics/memory.rst +++ b/docs/topics/memory.rst @@ -152,6 +152,14 @@ and :func:`~asyncio.server.serve` varies across implementations. use up to 4 bytes of memory per character, the queue may use up to ``4 * max_size * max_queue`` bytes of memory. By default, this is 128 MiB. -* In the :mod:`threading` implementation, there is no queue of incoming - messages. The ``max_queue`` argument doesn't exist. The connection keeps at - most one message in memory at a time. +* In the :mod:`threading` implementation, ``max_queue`` has the same semantics + as in the new :mod:`asyncio` implementation. It is the high-water mark of a + queue of incoming frames. It defaults to 16 frames. If the queue grows larger, + the connection stops reading from the network until the application consumes + messages and the queue goes below the low-water mark. This creates backpressure + on the TCP connection. + + Each item in the queue is a frame. A frame can be a message or a message + fragment. Either way, it must be smaller than ``max_size``, the maximum size + of a message. The queue may use up to ``max_size * max_queue`` bytes of + memory. By default, this is 16 MiB.