mirror of
https://github.com/python/cpython.git
synced 2025-08-15 06:10:47 +00:00
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
(cherry picked from commit d31b31516c
)
Co-authored-by: Xtreak <tir.karthi@gmail.com>
This commit is contained in:
parent
52c99aeb9f
commit
b9bfe143d1
3 changed files with 225 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue