diff options
author | Guido van Rossum <guido@dropbox.com> | 2013-10-18 22:17:11 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@dropbox.com> | 2013-10-18 22:17:11 (GMT) |
commit | 355491dc47ea4a2574ee8f9ea60a0d25fe3fba43 (patch) | |
tree | 2b9661e6f8c6d24704fae0c82467674802749d6d /Lib/asyncio/protocols.py | |
parent | 051a33148813d045c33745ccd0e9e20e96b1bb6f (diff) | |
download | cpython-355491dc47ea4a2574ee8f9ea60a0d25fe3fba43.zip cpython-355491dc47ea4a2574ee8f9ea60a0d25fe3fba43.tar.gz cpython-355491dc47ea4a2574ee8f9ea60a0d25fe3fba43.tar.bz2 |
Write flow control for asyncio (includes asyncio.streams overhaul).
Diffstat (limited to 'Lib/asyncio/protocols.py')
-rw-r--r-- | Lib/asyncio/protocols.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/asyncio/protocols.py b/Lib/asyncio/protocols.py index a94abbe..d3a8685 100644 --- a/Lib/asyncio/protocols.py +++ b/Lib/asyncio/protocols.py @@ -29,6 +29,34 @@ class BaseProtocol: aborted or closed). """ + def pause_writing(self): + """Called when the transport's buffer goes over the high-water mark. + + Pause and resume calls are paired -- pause_writing() is called + once when the buffer goes strictly over the high-water mark + (even if subsequent writes increases the buffer size even + more), and eventually resume_writing() is called once when the + buffer size reaches the low-water mark. + + Note that if the buffer size equals the high-water mark, + pause_writing() is not called -- it must go strictly over. + Conversely, resume_writing() is called when the buffer size is + equal or lower than the low-water mark. These end conditions + are important to ensure that things go as expected when either + mark is zero. + + NOTE: This is the only Protocol callback that is not called + through EventLoop.call_soon() -- if it were, it would have no + effect when it's most needed (when the app keeps writing + without yielding until pause_writing() is called). + """ + + def resume_writing(self): + """Called when the transport's buffer drains below the low-water mark. + + See pause_writing() for details. + """ + class Protocol(BaseProtocol): """ABC representing a protocol. |