Workaround for passing empty list to ray.wait. (#1043)

* Workaround for passing empty list to ray.wait.

* Add test for passing empty list to wait.
This commit is contained in:
Robert Nishihara 2017-10-01 11:45:02 -07:00 committed by Philipp Moritz
parent 79e013e876
commit ad61af7333
2 changed files with 11 additions and 0 deletions

View file

@ -2114,6 +2114,12 @@ def wait(object_ids, num_returns=1, timeout=None, worker=global_worker):
if worker.mode == PYTHON_MODE:
return object_ids[:num_returns], object_ids[num_returns:]
# TODO(rkn): This is a temporary workaround for
# https://github.com/ray-project/ray/issues/997. However, it should be
# fixed in Arrow instead of here.
if len(object_ids) == 0:
return [], []
object_id_strs = [plasma.ObjectID(object_id.id())
for object_id in object_ids]
timeout = timeout if timeout is not None else 2 ** 30

View file

@ -704,6 +704,11 @@ class APITest(unittest.TestCase):
x = ray.put(1)
self.assertRaises(Exception, lambda: ray.wait([x, x]))
# Make sure it is possible to call wait with an empty list.
ready_ids, remaining_ids = ray.wait([])
self.assertEqual(ready_ids, [])
self.assertEqual(remaining_ids, [])
def testMultipleWaitsAndGets(self):
# It is important to use three workers here, so that the three tasks
# launched in this experiment can run at the same time.