Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52bb949

Browse files
committed
asyncio, tulip issue 203: Add _FlowControlMixin.get_write_buffer_limits() method
1 parent b261475 commit 52bb949

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

Doc/library/asyncio-protocol.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ WriteTransport
121121

122122
Return the current size of the output buffer used by the transport.
123123

124+
.. method:: get_write_buffer_limits()
125+
126+
Get the *high*- and *low*-water limits for write flow control. Return a
127+
tuple ``(low, high)`` where *low* and *high* are positive number of
128+
bytes.
129+
130+
Use :meth:`set_write_buffer_limits` to set the limits.
131+
132+
.. versionadded:: 3.4.2
133+
124134
.. method:: set_write_buffer_limits(high=None, low=None)
125135

126136
Set the *high*- and *low*-water limits for write flow control.
@@ -141,6 +151,8 @@ WriteTransport
141151
reduces opportunities for doing I/O and computation
142152
concurrently.
143153

154+
Use :meth:`get_write_buffer_limits` to get the limits.
155+
144156
.. method:: write(data)
145157

146158
Write some *data* bytes to the transport.

Lib/asyncio/transports.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ def _maybe_resume_protocol(self):
273273
'protocol': self._protocol,
274274
})
275275

276+
def get_write_buffer_limits(self):
277+
return (self._low_water, self._high_water)
278+
276279
def _set_write_buffer_limits(self, high=None, low=None):
277280
if high is None:
278281
if low is None:

Lib/test/test_asyncio/test_transports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ def get_write_buffer_size(self):
7979

8080
transport.set_write_buffer_limits(high=1024, low=128)
8181
self.assertFalse(transport._protocol_paused)
82+
self.assertEqual(transport.get_write_buffer_limits(), (128, 1024))
8283

8384
transport.set_write_buffer_limits(high=256, low=128)
8485
self.assertTrue(transport._protocol_paused)
86+
self.assertEqual(transport.get_write_buffer_limits(), (128, 256))
8587

8688

8789
if __name__ == '__main__':

0 commit comments

Comments
 (0)