summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-24 16:33:20 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-24 16:33:20 (GMT)
commit4b4f9ebfea4148b9d483aefb24f88c18e1f505b4 (patch)
tree07008496fc74116e569666daaf4ff990a9015df7 /Doc/library
parent1374bd41b1e57fb47fcadc0fad9412f4618be317 (diff)
downloadcpython-4b4f9ebfea4148b9d483aefb24f88c18e1f505b4.zip
cpython-4b4f9ebfea4148b9d483aefb24f88c18e1f505b4.tar.gz
cpython-4b4f9ebfea4148b9d483aefb24f88c18e1f505b4.tar.bz2
asyncio doc: add a "Coroutines and protocols" section
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/asyncio-protocol.rst12
-rw-r--r--Doc/library/asyncio-stream.rst2
2 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst
index 9e02e84..d35c70d 100644
--- a/Doc/library/asyncio-protocol.rst
+++ b/Doc/library/asyncio-protocol.rst
@@ -403,6 +403,18 @@ buffer size reaches the low-water mark.
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
------
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index 0772516..f2a9f12 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -1,5 +1,7 @@
.. currentmodule:: asyncio
+.. _streams:
+
++++++++++++++++++++++++
Streams (high-level API)
++++++++++++++++++++++++