mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
[3.13] gh-127655: Ensure _SelectorSocketTransport.writelines
pauses the protocol if needed (GH-127656) (#127663)
gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (GH-127656)
Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed.
(cherry picked from commit e991ac8f20
)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
69bb1c6c41
commit
71e8429ac8
3 changed files with 14 additions and 0 deletions
|
@ -1175,6 +1175,7 @@ class _SelectorSocketTransport(_SelectorTransport):
|
|||
# If the entire buffer couldn't be written, register a write handler
|
||||
if self._buffer:
|
||||
self._loop._add_writer(self._sock_fd, self._write_ready)
|
||||
self._maybe_pause_protocol()
|
||||
|
||||
def can_write_eof(self):
|
||||
return True
|
||||
|
|
|
@ -805,6 +805,18 @@ class SelectorSocketTransportTests(test_utils.TestCase):
|
|||
self.assertTrue(self.sock.send.called)
|
||||
self.assertTrue(self.loop.writers)
|
||||
|
||||
def test_writelines_pauses_protocol(self):
|
||||
data = memoryview(b'data')
|
||||
self.sock.send.return_value = 2
|
||||
self.sock.send.fileno.return_value = 7
|
||||
|
||||
transport = self.socket_transport()
|
||||
transport._high_water = 1
|
||||
transport.writelines([data])
|
||||
self.assertTrue(self.protocol.pause_writing.called)
|
||||
self.assertTrue(self.sock.send.called)
|
||||
self.assertTrue(self.loop.writers)
|
||||
|
||||
@unittest.skipUnless(selector_events._HAS_SENDMSG, 'no sendmsg')
|
||||
def test_write_sendmsg_full(self):
|
||||
data = memoryview(b'data')
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fixed the :class:`!asyncio.selector_events._SelectorSocketTransport` transport not pausing writes for the protocol when the buffer reaches the high water mark when using :meth:`asyncio.WriteTransport.writelines`.
|
Loading…
Add table
Add a link
Reference in a new issue