Skip to content

Commit 708a88a

Browse files
committed
Clarify close() documentation
1 parent 9bbd936 commit 708a88a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Doc/library/asyncio-stream.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,20 @@ StreamReader
292292

293293
.. method:: close()
294294

295-
Invoke ``close()`` on the underlying transport (if one exists).
295+
Invoke ``close()`` on the underlying asyncio transport (if one exists).
296+
297+
Note: It is not necessary for code that is given an already
298+
instantiated :class:`StreamReader` instance to call `close()`
299+
for the sake of cleaning up resources when it is done using
300+
it. Cleanup of the underlying transport is the
301+
reponsibility of the code that provided the
302+
:class:`StreamReader` instance. This method exists purely to
303+
allow client code of APIs that hide the underlying transport to
304+
eagerly close the transport as a way to signal to the producer
305+
of the stream that the read side is shut down. In particular,
306+
when interacting with the standard out pipe of a sub-process.
307+
In other words, it is an error to not to call close() on
308+
:class:`StreamReader` instance you've been given.
296309

297310

298311
StreamWriter

0 commit comments

Comments
 (0)