From 165ba64f685b1bce6dfe4c70758f1ba15ac160a4 Mon Sep 17 00:00:00 2001 From: Shaisolaris <66793913+Shaisolaris@users.noreply.github.com> Date: Mon, 12 Oct 2026 02:26:31 -0700 Subject: [PATCH] Fix the default write buffer low-water mark UVBaseTransport set its initial low-water mark to FLOW_CONTROL_HIGH_WATER // 4, which is 16 bytes, while the high-water mark is FLOW_CONTROL_HIGH_WATER * 1024. asyncio and set_write_buffer_limits() both use high // 4, which is 16 KiB. --- tests/test_tcp.py | 2 ++ uvloop/handles/basetransport.pyx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_tcp.py b/tests/test_tcp.py index b933166b7..1f9392106 100644 --- a/tests/test_tcp.py +++ b/tests/test_tcp.py @@ -1349,6 +1349,8 @@ def resume_writing(self): t, p = await self.loop.create_connection(Protocol, *addr) + self.assertEqual(t.get_write_buffer_limits(), (16384, 65536)) + t.write(b'q' * 512) t.set_write_buffer_limits(low=16385) self.assertEqual(t.get_write_buffer_limits(), (16385, 65540)) diff --git a/uvloop/handles/basetransport.pyx b/uvloop/handles/basetransport.pyx index 28b307947..246865760 100644 --- a/uvloop/handles/basetransport.pyx +++ b/uvloop/handles/basetransport.pyx @@ -3,7 +3,7 @@ cdef class UVBaseTransport(UVSocketHandle): def __cinit__(self): # Flow control self._high_water = FLOW_CONTROL_HIGH_WATER * 1024 - self._low_water = FLOW_CONTROL_HIGH_WATER // 4 + self._low_water = FLOW_CONTROL_HIGH_WATER * 1024 // 4 self._protocol = None self._protocol_connected = 0