[Python-checkins] cpython (merge 3.5 -> 3.6): Issue #29407: Merge from 3.5
berker.peksag
python-checkins at python.org
Wed Feb 1 14:33:23 EST 2017
https://hg.python.org/cpython/rev/7196ab02b7ce
changeset: 106369:7196ab02b7ce
branch: 3.6
parent: 106360:a19ce80e9fa3
parent: 106368:e4f6874abda6
user: Berker Peksag <berker.peksag at gmail.com>
date: Wed Feb 01 22:37:49 2017 +0300
summary:
Issue #29407: Merge from 3.5
files:
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
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -472,21 +472,20 @@
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::
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list