Skip to content

Commit

Permalink
Use asyncio.gather instead of asyncio.wait in example.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
asvetlov committed Aug 8, 2016
1 parent 9854789 commit 4365b83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down

0 comments on commit 4365b83

Please sign in to comment.