summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2017-02-07 11:28:19 +0300
committerBerker Peksag <berker.peksag@gmail.com>2017-02-07 11:28:19 +0300
commit3104a00c4403037b094bd476e1c8cd3fc4341e5f (patch)
treed0da3cfc54de77eab5bd92cb806865682d3de24e
parent76257c944849d2c75256c8cc89a95b0c0d709b7e (diff)
parent819a21a3a4aac38f32e1ba4f68bcef45591fa3f0 (diff)
downloadcpython-3104a00c4403037b094bd476e1c8cd3fc4341e5f.tar.gz
Issue #29441: Merge from 3.6
-rw-r--r--Doc/library/asyncio-task.rst21
1 files changed, 4 insertions, 17 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index 90cb9c364f..558d17c096 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -136,17 +136,6 @@ using the :meth:`sleep` function::
loop.run_until_complete(display_date(loop))
loop.close()
-The same coroutine implemented using a generator::
-
- @asyncio.coroutine
- def display_date(loop):
- end_time = loop.time() + 5.0
- while True:
- print(datetime.datetime.now())
- if (loop.time() + 1.0) >= end_time:
- break
- yield from asyncio.sleep(1)
-
.. seealso::
The :ref:`display the current date with call_later()
@@ -309,9 +298,8 @@ Example combining a :class:`Future` and a :ref:`coroutine function
import asyncio
- @asyncio.coroutine
- def slow_operation(future):
- yield from asyncio.sleep(1)
+ async def slow_operation(future):
+ await asyncio.sleep(1)
future.set_result('Future is done!')
loop = asyncio.get_event_loop()
@@ -341,9 +329,8 @@ flow::
import asyncio
- @asyncio.coroutine
- def slow_operation(future):
- yield from asyncio.sleep(1)
+ async def slow_operation(future):
+ await asyncio.sleep(1)
future.set_result('Future is done!')
def got_result(future):