@@ -20,13 +20,13 @@ streams::
2020 '127.0.0.1', 8888)
2121
2222 print(f'Send: {message!r}')
23- writer.write (message.encode())
23+ await writer.awrite (message.encode())
2424
2525 data = await reader.read(100)
2626 print(f'Received: {data.decode()!r}')
2727
2828 print('Close the connection')
29- writer.close ()
29+ await writer.aclose ()
3030
3131 asyncio.run(tcp_echo_client('Hello World!'))
3232
@@ -229,14 +229,57 @@ StreamWriter
229229 directly; use :func: `open_connection ` and :func: `start_server `
230230 instead.
231231
232+ .. coroutinemethod :: awrite(data)
233+
234+ Write *data * to the stream.
235+
236+ The method respects control-flow, execution is paused if write
237+ buffer reaches high-water limit.
238+
239+ .. versionadded :: 3.8
240+
241+ .. coroutinemethod :: aclose()
242+
243+ Close the stream.
244+
245+ Wait for finishing all closing actions, e.g. SSL shutdown for
246+ secure sockets.
247+
248+ .. versionadded :: 3.8
249+
250+ .. method :: can_write_eof()
251+
252+ Return *True * if the underlying transport supports
253+ the :meth: `write_eof ` method, *False * otherwise.
254+
255+ .. method :: write_eof()
256+
257+ Close the write end of the stream after the buffered write
258+ data is flushed.
259+
260+ .. attribute :: transport
261+
262+ Return the underlying asyncio transport.
263+
264+ .. method :: get_extra_info(name, default=None)
265+
266+ Access optional transport information; see
267+ :meth: `BaseTransport.get_extra_info ` for details.
268+
232269 .. method :: write(data)
233270
234271 Write *data * to the stream.
235272
273+ This method doesn't apply control-flow. The call should be
274+ followed by :meth: `drain `.
275+
236276 .. method :: writelines(data)
237277
238278 Write a list (or any iterable) of bytes to the stream.
239279
280+ This method doesn't apply control-flow. The call should be
281+ followed by :meth: `drain `.
282+
240283 .. coroutinemethod :: drain()
241284
242285 Wait until it is appropriate to resume writing to the stream.
@@ -272,25 +315,6 @@ StreamWriter
272315
273316 .. versionadded :: 3.7
274317
275- .. method :: can_write_eof()
276-
277- Return *True * if the underlying transport supports
278- the :meth: `write_eof ` method, *False * otherwise.
279-
280- .. method :: write_eof()
281-
282- Close the write end of the stream after the buffered write
283- data is flushed.
284-
285- .. attribute :: transport
286-
287- Return the underlying asyncio transport.
288-
289- .. method :: get_extra_info(name, default=None)
290-
291- Access optional transport information; see
292- :meth: `BaseTransport.get_extra_info ` for details.
293-
294318
295319Examples
296320========
0 commit comments