From: Victor Stinner Date: Thu, 12 Dec 2013 11:35:17 +0000 (+0100) Subject: Add a sequence diagram for the chained coroutines example X-Git-Tag: v3.4.0b2~251 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1c4b892d71cad83efcafc88ab6c57ebd0d50a633;p=thirdparty%2FPython%2Fcpython.git Add a sequence diagram for the chained coroutines example --- diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index afcfea84a2aa..836125740212 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 `. @@ -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 000000000000..c4e19a066589 Binary files /dev/null and b/Doc/library/tulip_coro.dia differ diff --git a/Doc/library/tulip_coro.png b/Doc/library/tulip_coro.png new file mode 100644 index 000000000000..e083bc37de88 Binary files /dev/null and b/Doc/library/tulip_coro.png differ