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

Skip to content

Commit e718297

Browse files
committed
Closes #22348: Rephrase asyncio.StreamWriter.drain() documentation
Patch written by Martin Richard.
1 parent 1deee54 commit e718297

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Doc/library/asyncio-stream.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,22 @@ StreamWriter
170170

171171
.. method:: drain()
172172

173-
Wait until the write buffer of the underlying transport is flushed.
173+
Let the write buffer of the underlying transport a chance to be flushed.
174174

175175
The intended use is to write::
176176

177177
w.write(data)
178178
yield from w.drain()
179179

180-
When the transport buffer is full (the protocol is paused), block until
181-
the buffer is (partially) drained and the protocol is resumed. When there
182-
is nothing to wait for, the yield-from continues immediately.
180+
When the size of the transport buffer reaches the high-water limit (the
181+
protocol is paused), block until the size of the buffer is drained down
182+
to the low-water limit and the protocol is resumed. When there is nothing
183+
to wait for, the yield-from continues immediately.
184+
185+
Yielding from :meth:`drain` gives the opportunity for the loop to
186+
schedule the write operation and flush the buffer. It should especially
187+
be used when a possibly large amount of data is written to the transport,
188+
and the coroutine does not yield-from between calls to :meth:`write`.
183189

184190
This method is a :ref:`coroutine <coroutine>`.
185191

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ Francesco Ricciardi
11251125
Tim Rice
11261126
Jan Pieter Riegel
11271127
Armin Rigo
1128+
Martin Richard
11281129
Arc Riley
11291130
Nicholas Riley
11301131
Jean-Claude Rimbault

0 commit comments

Comments
 (0)