Skip to content

Commit

Permalink
Raise informative error when using as_completed with non-futures (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Jan 9, 2017
1 parent b9c01bb commit 6cc922f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions distributed/client.py
Expand Up @@ -2363,6 +2363,10 @@ def as_completed(fs):
fs = list(fs)
if not fs:
return
non_futures = [f for f in fs if not isinstance(f, Future)]
if non_futures:
raise TypeError("Using as_completed on non-future objects: %s" %
non_futures)
if len(set(f.client for f in fs)) == 1:
loop = first(fs).client.loop
else:
Expand Down
7 changes: 7 additions & 0 deletions distributed/tests/test_client.py
Expand Up @@ -403,6 +403,13 @@ def test_as_completed(loop):
assert list(as_completed([])) == []


def test_as_completed_with_non_futures(loop):
with cluster() as (s, [a, b]):
with Client(('127.0.0.1', s['port']), loop=loop) as c:
with pytest.raises(TypeError):
list(as_completed([1, 2, 3]))


def test_wait_sync(loop):
with cluster() as (s, [a, b]):
with Client(('127.0.0.1', s['port']), loop=loop) as c:
Expand Down

0 comments on commit 6cc922f

Please sign in to comment.