summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2018-09-13 23:53:49 (GMT)
committerGitHub <noreply@github.com>2018-09-13 23:53:49 (GMT)
commit11194c877c902a6c3b769d85be887c2272e0a541 (patch)
tree8181f75217256e9035a177cee53916e4fa6eacab /Doc
parent413118ebf3162418639a5c4af14b02d26571a02c (diff)
downloadcpython-11194c877c902a6c3b769d85be887c2272e0a541.zip
cpython-11194c877c902a6c3b769d85be887c2272e0a541.tar.gz
cpython-11194c877c902a6c3b769d85be887c2272e0a541.tar.bz2
bpo-34666: Implement stream.awrite() and stream.aclose() (GH-9274)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/asyncio-stream.rst66
1 files changed, 45 insertions, 21 deletions
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index 0cfecda..80b7625 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -20,13 +20,13 @@ streams::
'127.0.0.1', 8888)
print(f'Send: {message!r}')
- writer.write(message.encode())
+ await writer.awrite(message.encode())
data = await reader.read(100)
print(f'Received: {data.decode()!r}')
print('Close the connection')
- writer.close()
+ await writer.aclose()
asyncio.run(tcp_echo_client('Hello World!'))
@@ -229,14 +229,57 @@ StreamWriter
directly; use :func:`open_connection` and :func:`start_server`
instead.
+ .. coroutinemethod:: awrite(data)
+
+ Write *data* to the stream.
+
+ The method respects control-flow, execution is paused if write
+ buffer reaches high-water limit.
+
+ .. versionadded:: 3.8
+
+ .. coroutinemethod:: aclose()
+
+ Close the stream.
+
+ Wait for finishing all closing actions, e.g. SSL shutdown for
+ secure sockets.
+
+ .. versionadded:: 3.8
+
+ .. method:: can_write_eof()
+
+ Return *True* if the underlying transport supports
+ the :meth:`write_eof` method, *False* otherwise.
+
+ .. method:: write_eof()
+
+ Close the write end of the stream after the buffered write
+ data is flushed.
+
+ .. attribute:: transport
+
+ Return the underlying asyncio transport.
+
+ .. method:: get_extra_info(name, default=None)
+
+ Access optional transport information; see
+ :meth:`BaseTransport.get_extra_info` for details.
+
.. method:: write(data)
Write *data* to the stream.
+ This method doesn't apply control-flow. The call should be
+ followed by :meth:`drain`.
+
.. method:: writelines(data)
Write a list (or any iterable) of bytes to the stream.
+ This method doesn't apply control-flow. The call should be
+ followed by :meth:`drain`.
+
.. coroutinemethod:: drain()
Wait until it is appropriate to resume writing to the stream.
@@ -272,25 +315,6 @@ StreamWriter
.. versionadded:: 3.7
- .. method:: can_write_eof()
-
- Return *True* if the underlying transport supports
- the :meth:`write_eof` method, *False* otherwise.
-
- .. method:: write_eof()
-
- Close the write end of the stream after the buffered write
- data is flushed.
-
- .. attribute:: transport
-
- Return the underlying asyncio transport.
-
- .. method:: get_extra_info(name, default=None)
-
- Access optional transport information; see
- :meth:`BaseTransport.get_extra_info` for details.
-
Examples
========