diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2017-02-01 19:37:49 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2017-02-01 19:37:49 (GMT) |
commit | c6fe419d1b3e1476d804a40809c2c5b954581c0d (patch) | |
tree | 19c7f9043bd7c82d1b25cb1f6500058655ebc1bf /Doc | |
parent | f8c5f3030305cc0e5d61ddd443fec48446890a11 (diff) | |
parent | d5adb63673de2dea890615f75cf1a1305c3bdea1 (diff) | |
download | cpython-c6fe419d1b3e1476d804a40809c2c5b954581c0d.zip cpython-c6fe419d1b3e1476d804a40809c2c5b954581c0d.tar.gz cpython-c6fe419d1b3e1476d804a40809c2c5b954581c0d.tar.bz2 |
Issue #29407: Merge from 3.5
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-task.rst | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 9bff1c4..90cb9c3 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -472,21 +472,20 @@ Example executing 3 tasks (A, B, C) in parallel:: import asyncio - @asyncio.coroutine - def factorial(name, number): + async def factorial(name, number): f = 1 for i in range(2, number+1): print("Task %s: Compute factorial(%s)..." % (name, i)) - yield from asyncio.sleep(1) + await asyncio.sleep(1) f *= i print("Task %s: factorial(%s) = %s" % (name, number, f)) loop = asyncio.get_event_loop() - tasks = [ - asyncio.ensure_future(factorial("A", 2)), - asyncio.ensure_future(factorial("B", 3)), - asyncio.ensure_future(factorial("C", 4))] - loop.run_until_complete(asyncio.gather(*tasks)) + loop.run_until_complete(asyncio.gather( + factorial("A", 2), + factorial("B", 3), + factorial("C", 4), + )) loop.close() Output:: |