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
This commit is contained in:
Xtreak 2019-09-13 11:52:38 +01:00 committed by Miss Islington (bot)
parent 6a517c6749
commit d31b31516c
3 changed files with 225 additions and 11 deletions

View file

@ -70,6 +70,13 @@ def connect(host=None, port=None, *,
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 @@ async def _connect(host, port,
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 @@ async def _connect_read_pipe(pipe, limit):
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