summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-28 16:45:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-11-28 16:45:41 (GMT)
commite7182979d6e8178e4bbcc50beb142624b1a88223 (patch)
treed616a621c55aad158314e14a7db1437e4fb05b6e
parent1deee54e0cb0f681779259758a30f4fe142f1477 (diff)
downloadcpython-e7182979d6e8178e4bbcc50beb142624b1a88223.zip
cpython-e7182979d6e8178e4bbcc50beb142624b1a88223.tar.gz
cpython-e7182979d6e8178e4bbcc50beb142624b1a88223.tar.bz2
Closes #22348: Rephrase asyncio.StreamWriter.drain() documentation
Patch written by Martin Richard.
-rw-r--r--Doc/library/asyncio-stream.rst14
-rw-r--r--Misc/ACKS1
2 files changed, 11 insertions, 4 deletions
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index 348132a..3809d94 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -170,16 +170,22 @@ StreamWriter
.. method:: drain()
- Wait until the write buffer of the underlying transport is flushed.
+ Let the write buffer of the underlying transport a chance to be flushed.
The intended use is to write::
w.write(data)
yield from w.drain()
- When the transport buffer is full (the protocol is paused), block until
- the buffer is (partially) drained and the protocol is resumed. When there
- is nothing to wait for, the yield-from continues immediately.
+ When the size of the transport buffer reaches the high-water limit (the
+ protocol is paused), block until the size of the buffer is drained down
+ to the low-water limit and the protocol is resumed. When there is nothing
+ to wait for, the yield-from continues immediately.
+
+ Yielding from :meth:`drain` gives the opportunity for the loop to
+ schedule the write operation and flush the buffer. It should especially
+ be used when a possibly large amount of data is written to the transport,
+ and the coroutine does not yield-from between calls to :meth:`write`.
This method is a :ref:`coroutine <coroutine>`.
diff --git a/Misc/ACKS b/Misc/ACKS
index 30b6a0e..d4ec659 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1125,6 +1125,7 @@ Francesco Ricciardi
Tim Rice
Jan Pieter Riegel
Armin Rigo
+Martin Richard
Arc Riley
Nicholas Riley
Jean-Claude Rimbault