mirror of https://github.com/python/cpython.git
asyncio doc: add a "Coroutines and protocols" section
This commit is contained in:
parent
1374bd41b1
commit
4b4f9ebfea
|
@ -403,6 +403,18 @@ buffer size reaches the low-water mark.
|
||||||
mark is zero.
|
mark is zero.
|
||||||
|
|
||||||
|
|
||||||
|
Coroutines and protocols
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Coroutines can be scheduled in a protocol method using :func:`async`, but there
|
||||||
|
is not guarantee on the execution order. Protocols are not aware of coroutines
|
||||||
|
created in protocol methods and so will not wait for them.
|
||||||
|
|
||||||
|
To have a reliable execution order, use :ref:`stream objects <streams>` in a
|
||||||
|
coroutine with ``yield from``. For example, the :meth:`StreamWriter.drain`
|
||||||
|
coroutine can be used to wait until the write buffer is flushed.
|
||||||
|
|
||||||
|
|
||||||
Server
|
Server
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
.. currentmodule:: asyncio
|
.. currentmodule:: asyncio
|
||||||
|
|
||||||
|
.. _streams:
|
||||||
|
|
||||||
++++++++++++++++++++++++
|
++++++++++++++++++++++++
|
||||||
Streams (high-level API)
|
Streams (high-level API)
|
||||||
++++++++++++++++++++++++
|
++++++++++++++++++++++++
|
||||||
|
|
Loading…
Reference in New Issue