Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c6fe419d
Commit
c6fe419d
authored
Feb 01, 2017
by
Berker Peksag
Browse files
Options
Browse Files
Download
Plain Diff
Issue #29407: Merge from 3.5
parents
f8c5f303
d5adb636
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
Doc/library/asyncio-task.rst
Doc/library/asyncio-task.rst
+7
-8
No files found.
Doc/library/asyncio-task.rst
View file @
c6fe419d
...
...
@@ -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::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment