[Python-checkins] cpython (3.5): Use asyncio.gather instead of asyncio.wait in example.

andrew.svetlov python-checkins at python.org
Sun Aug 7 20:11:14 EDT 2016


https://hg.python.org/cpython/rev/59c9b99f545e
changeset:   102562:59c9b99f545e
branch:      3.5
parent:      102559:e947248100ae
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Mon Aug 08 03:10:39 2016 +0300
summary:
  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.

files:
  Doc/library/asyncio-task.rst |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -486,7 +486,7 @@
         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::

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list