@@ -22,13 +22,13 @@ streams::
2222 '127.0.0.1', 8888)
2323
2424 print(f'Send: {message!r}')
25- await writer.awrite (message.encode())
25+ await writer.write (message.encode())
2626
2727 data = await reader.read(100)
2828 print(f'Received: {data.decode()!r}')
2929
3030 print('Close the connection')
31- await writer.aclose ()
31+ await writer.close ()
3232
3333 asyncio.run(tcp_echo_client('Hello World!'))
3434
@@ -226,23 +226,70 @@ StreamWriter
226226 directly; use :func: `open_connection ` and :func: `start_server `
227227 instead.
228228
229- .. coroutinemethod :: awrite(data)
229+ .. method :: write(data)
230+
231+ The method attempts to write the *data * to the underlying socket immediately.
232+ If that fails, the data is queued in an internal write buffer until it can be
233+ sent.
234+
235+ Starting with Python 3.8, it is possible to directly await on the `write() `
236+ method::
237+
238+ await stream.write(data)
239+
240+ The ``await `` pauses the current coroutine until the data is written to the
241+ socket.
242+
243+ Below is an equivalent code that works with Python <= 3.7::
244+
245+ stream.write(data)
246+ await stream.drain()
247+
248+ .. versionchanged :: 3.8
249+ Support ``await stream.write(...) `` syntax.
250+
251+ .. method :: writelines(data)
252+
253+ The method writes a list (or any iterable) of bytes to the underlying socket
254+ immediately.
255+ If that fails, the data is queued in an internal write buffer until it can be
256+ sent.
257+
258+ Starting with Python 3.8, it is possible to directly await on the `write() `
259+ method::
260+
261+ await stream.writelines(lines)
262+
263+ The ``await `` pauses the current coroutine until the data is written to the
264+ socket.
265+
266+ Below is an equivalent code that works with Python <= 3.7::
230267
231- Write *data * to the stream.
268+ stream.writelines(lines)
269+ await stream.drain()
232270
233- The method respects flow control, execution is paused if the write
234- buffer reaches the high watermark .
271+ .. versionchanged :: 3.8
272+ Support `` await stream.writelines() `` syntax .
235273
236- .. versionadded :: 3.8
274+ .. method :: close()
275+
276+ The method closes the stream and the underlying socket.
277+
278+ Starting with Python 3.8, it is possible to directly await on the `close() `
279+ method::
280+
281+ await stream.close()
237282
238- .. coroutinemethod :: aclose()
283+ The ``await `` pauses the current coroutine until the stream and the underlying
284+ socket are closed (and SSL shutdown is performed for a secure connection).
239285
240- Close the stream.
286+ Below is an equivalent code that works with Python <= 3.7::
241287
242- Wait until all closing actions are complete, e.g. SSL shutdown for
243- secure sockets.
288+ stream.close()
289+ await stream.wait_closed()
244290
245- .. versionadded :: 3.8
291+ .. versionchanged :: 3.8
292+ Support ``await stream.close() `` syntax.
246293
247294 .. method :: can_write_eof()
248295
@@ -263,21 +310,6 @@ StreamWriter
263310 Access optional transport information; see
264311 :meth: `BaseTransport.get_extra_info ` for details.
265312
266- .. method :: write(data)
267-
268- Write *data * to the stream.
269-
270- This method is not subject to flow control. Calls to ``write() `` should
271- be followed by :meth: `drain `. The :meth: `awrite ` method is a
272- recommended alternative the applies flow control automatically.
273-
274- .. method :: writelines(data)
275-
276- Write a list (or any iterable) of bytes to the stream.
277-
278- This method is not subject to flow control. Calls to ``writelines() ``
279- should be followed by :meth: `drain `.
280-
281313 .. coroutinemethod :: drain()
282314
283315 Wait until it is appropriate to resume writing to the stream.
@@ -293,10 +325,6 @@ StreamWriter
293325 be resumed. When there is nothing to wait for, the :meth: `drain `
294326 returns immediately.
295327
296- .. method :: close()
297-
298- Close the stream.
299-
300328 .. method :: is_closing()
301329
302330 Return ``True `` if the stream is closed or in the process of
0 commit comments