summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-12 12:35:17 +0100
committerVictor Stinner <victor.stinner@gmail.com>2013-12-12 12:35:17 +0100
commit1c4b892d71cad83efcafc88ab6c57ebd0d50a633 (patch)
tree1d0d1d9f50cf8257d51eccf2d974e22a8bb0c2e5
parentf06247d16a7210cb5c8645d7244dd45a08ccc834 (diff)
downloadcpython-git-1c4b892d71cad83efcafc88ab6c57ebd0d50a633.tar.gz
Add a sequence diagram for the chained coroutines example
-rw-r--r--Doc/library/asyncio-task.rst11
-rw-r--r--Doc/library/tulip_coro.diabin0 -> 4332 bytes
-rw-r--r--Doc/library/tulip_coro.pngbin0 -> 46386 bytes
3 files changed, 10 insertions, 1 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index afcfea84a2..8361257402 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -74,7 +74,6 @@ Print ``"Hello World"`` every two seconds using a coroutine::
loop = asyncio.get_event_loop()
loop.run_until_complete(greet_every_two_seconds())
-
.. seealso::
:ref:`Hello World example using a callback <asyncio-hello-world-callback>`.
@@ -104,6 +103,16 @@ Example chaining coroutines::
``compute()`` is chained to ``print_sum()``: ``print_sum()`` coroutine waits
until ``compute()`` is completed before returing its result.
+Sequence diagram of the example:
+
+.. image:: tulip_coro.png
+ :align: center
+
+The diagram shows the logical links between the task and the two coroutines, it
+does not describe exactly how things work internally. For example, the sleep
+coroutine creates an internal future which uses
+:meth:`BaseEventLoop.call_later` to wake up the task in 1 second.
+
InvalidStateError
-----------------
diff --git a/Doc/library/tulip_coro.dia b/Doc/library/tulip_coro.dia
new file mode 100644
index 0000000000..c4e19a0665
--- /dev/null
+++ b/Doc/library/tulip_coro.dia
Binary files differ
diff --git a/Doc/library/tulip_coro.png b/Doc/library/tulip_coro.png
new file mode 100644
index 0000000000..e083bc37de
--- /dev/null
+++ b/Doc/library/tulip_coro.png
Binary files differ