summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-08-25 22:22:28 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-08-25 22:22:28 (GMT)
commit52bb949fd3658957fb8719fd83183b38d9fb621c (patch)
treea445a45fe33a5e30f25d3cbaa213519658b6d637
parentb261475a48d905f160bc1f499e90b995b0d0b6c0 (diff)
downloadcpython-52bb949fd3658957fb8719fd83183b38d9fb621c.zip
cpython-52bb949fd3658957fb8719fd83183b38d9fb621c.tar.gz
cpython-52bb949fd3658957fb8719fd83183b38d9fb621c.tar.bz2
asyncio, tulip issue 203: Add _FlowControlMixin.get_write_buffer_limits() method
-rw-r--r--Doc/library/asyncio-protocol.rst12
-rw-r--r--Lib/asyncio/transports.py3
-rw-r--r--Lib/test/test_asyncio/test_transports.py2
3 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst
index 952ab69..92b055a 100644
--- a/Doc/library/asyncio-protocol.rst
+++ b/Doc/library/asyncio-protocol.rst
@@ -121,6 +121,16 @@ WriteTransport
Return the current size of the output buffer used by the transport.
+ .. method:: get_write_buffer_limits()
+
+ Get the *high*- and *low*-water limits for write flow control. Return a
+ tuple ``(low, high)`` where *low* and *high* are positive number of
+ bytes.
+
+ Use :meth:`set_write_buffer_limits` to set the limits.
+
+ .. versionadded:: 3.4.2
+
.. method:: set_write_buffer_limits(high=None, low=None)
Set the *high*- and *low*-water limits for write flow control.
@@ -141,6 +151,8 @@ WriteTransport
reduces opportunities for doing I/O and computation
concurrently.
+ Use :meth:`get_write_buffer_limits` to get the limits.
+
.. method:: write(data)
Write some *data* bytes to the transport.
diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py
index 5f674f9..3caf853 100644
--- a/Lib/asyncio/transports.py
+++ b/Lib/asyncio/transports.py
@@ -273,6 +273,9 @@ class _FlowControlMixin(Transport):
'protocol': self._protocol,
})
+ def get_write_buffer_limits(self):
+ return (self._low_water, self._high_water)
+
def _set_write_buffer_limits(self, high=None, low=None):
if high is None:
if low is None:
diff --git a/Lib/test/test_asyncio/test_transports.py b/Lib/test/test_asyncio/test_transports.py
index cfbdf3e..5be1b7b 100644
--- a/Lib/test/test_asyncio/test_transports.py
+++ b/Lib/test/test_asyncio/test_transports.py
@@ -79,9 +79,11 @@ class TransportTests(unittest.TestCase):
transport.set_write_buffer_limits(high=1024, low=128)
self.assertFalse(transport._protocol_paused)
+ self.assertEqual(transport.get_write_buffer_limits(), (128, 1024))
transport.set_write_buffer_limits(high=256, low=128)
self.assertTrue(transport._protocol_paused)
+ self.assertEqual(transport.get_write_buffer_limits(), (128, 256))
if __name__ == '__main__':