bpo-36889: Document Stream class and add docstrings (GH-14488)
* This just copies the docs from `StreamWriter` and `StreamReader`.
* Add docstring for asyncio functions.
https://bugs.python.org/issue36889
Automerge-Triggered-By: @asvetlov
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 4943e8e..b709dc1 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -70,6 +70,13 @@
server_hostname=None,
ssl_handshake_timeout=None,
happy_eyeballs_delay=None, interleave=None):
+ """Connect to TCP socket on *host* : *port* address to send and receive data.
+
+ *limit* determines the buffer size limit used by the returned `Stream`
+ instance. By default the *limit* is set to 64 KiB.
+
+ The rest of the arguments are passed directly to `loop.create_connection()`.
+ """
# Design note:
# Don't use decorator approach but explicit non-async
# function to fail fast and explicitly
@@ -108,6 +115,13 @@
def connect_read_pipe(pipe, *, limit=_DEFAULT_LIMIT):
+ """Establish a connection to a file-like object *pipe* to receive data.
+
+ Takes a file-like object *pipe* to return a Stream object of the mode
+ StreamMode.READ that has similar API of StreamReader. It can also be used
+ as an async context manager.
+ """
+
# Design note:
# Don't use decorator approach but explicit non-async
# function to fail fast and explicitly
@@ -129,6 +143,13 @@
def connect_write_pipe(pipe, *, limit=_DEFAULT_LIMIT):
+ """Establish a connection to a file-like object *pipe* to send data.
+
+ Takes a file-like object *pipe* to return a Stream object of the mode
+ StreamMode.WRITE that has similar API of StreamWriter. It can also be used
+ as an async context manager.
+ """
+
# Design note:
# Don't use decorator approach but explicit non-async
# function to fail fast and explicitly