summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-11 10:54:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-11 10:54:08 (GMT)
commiteb74876e9939bfa9e30cd2e8894ab827cc2296b4 (patch)
tree5fd1c34466f1a6e881a4ed29d2b5c0b6aa44847c /Lib/asyncio
parent4e8d2f25e23d1da33d414074485da8e374d98495 (diff)
downloadcpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.zip
cpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.tar.gz
cpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.tar.bz2
asyncio, Tulip issue 131: as_completed() and wait() now raises a TypeError if
the list of futures is not a list but a Future, Task or coroutine object
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/tasks.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 5ad0652..81a125f 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -358,6 +358,8 @@ def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED):
Note: This does not raise TimeoutError! Futures that aren't done
when the timeout occurs are returned in the second set.
"""
+ if isinstance(fs, futures.Future) or iscoroutine(fs):
+ raise TypeError("expect a list of futures, not %s" % type(fs).__name__)
if not fs:
raise ValueError('Set of coroutines/Futures is empty.')
@@ -474,6 +476,8 @@ def as_completed(fs, *, loop=None, timeout=None):
Note: The futures 'f' are not necessarily members of fs.
"""
+ if isinstance(fs, futures.Future) or iscoroutine(fs):
+ raise TypeError("expect a list of futures, not %s" % type(fs).__name__)
loop = loop if loop is not None else events.get_event_loop()
deadline = None if timeout is None else loop.time() + timeout
todo = {async(f, loop=loop) for f in set(fs)}