Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4365b83

Browse files
committed
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.
1 parent 9854789 commit 4365b83

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Example executing 3 tasks (A, B, C) in parallel::
486486
asyncio.ensure_future(factorial("A", 2)),
487487
asyncio.ensure_future(factorial("B", 3)),
488488
asyncio.ensure_future(factorial("C", 4))]
489-
loop.run_until_complete(asyncio.wait(tasks))
489+
loop.run_until_complete(asyncio.gather(*tasks))
490490
loop.close()
491491

492492
Output::

0 commit comments

Comments
 (0)