asyncio doc: simplify task example

This commit is contained in:
Victor Stinner 2013-12-10 12:20:14 +01:00
parent 0839ed4730
commit a6fa15367f
1 changed files with 4 additions and 4 deletions

View File

@ -327,10 +327,10 @@ Example executing 3 tasks (A, B, C) in parallel::
f *= i f *= i
print("Task %s: factorial(%s) = %s" % (name, number, f)) print("Task %s: factorial(%s) = %s" % (name, number, f))
task_a = asyncio.Task(factorial("A", 2)) tasks = [
task_b = asyncio.Task(factorial("B", 3)) asyncio.Task(factorial("A", 2)),
task_c = asyncio.Task(factorial("C", 4)) asyncio.Task(factorial("B", 3)),
tasks = [task_a, task_b, task_c] asyncio.Task(factorial("C", 4))]
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks)) loop.run_until_complete(asyncio.wait(tasks))