Use asyncio.gather instead of asyncio.wait in example.

gather will raise exception in case of problem but wait just returns done and pending lists of futures.
For getting error every future result should be retrieved, which is boring and error prone.
This commit is contained in:
Andrew Svetlov 2016-08-08 03:10:39 +03:00
parent 9854789efe
commit 4365b8302d
1 changed files with 1 additions and 1 deletions

View File

@ -486,7 +486,7 @@ Example executing 3 tasks (A, B, C) in parallel::
asyncio.ensure_future(factorial("A", 2)),
asyncio.ensure_future(factorial("B", 3)),
asyncio.ensure_future(factorial("C", 4))]
loop.run_until_complete(asyncio.wait(tasks))
loop.run_until_complete(asyncio.gather(*tasks))
loop.close()
Output::