asyncio doc: simplify task example
This commit is contained in:
parent
0839ed4730
commit
a6fa15367f
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue