Commit e7182979 authored by Victor Stinner's avatar Victor Stinner

Closes #22348: Rephrase asyncio.StreamWriter.drain() documentation

Patch written by Martin Richard.
parent 1deee54e
...@@ -170,16 +170,22 @@ StreamWriter ...@@ -170,16 +170,22 @@ StreamWriter
.. method:: drain() .. 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:: The intended use is to write::
w.write(data) w.write(data)
yield from w.drain() yield from w.drain()
When the transport buffer is full (the protocol is paused), block until When the size of the transport buffer reaches the high-water limit (the
the buffer is (partially) drained and the protocol is resumed. When there protocol is paused), block until the size of the buffer is drained down
is nothing to wait for, the yield-from continues immediately. 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>`. This method is a :ref:`coroutine <coroutine>`.
......
...@@ -1125,6 +1125,7 @@ Francesco Ricciardi ...@@ -1125,6 +1125,7 @@ Francesco Ricciardi
Tim Rice Tim Rice
Jan Pieter Riegel Jan Pieter Riegel
Armin Rigo Armin Rigo
Martin Richard
Arc Riley Arc Riley
Nicholas Riley Nicholas Riley
Jean-Claude Rimbault Jean-Claude Rimbault
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment