Implement select to enable waiting for a specific number of remote objects to be ready. (#369)

This commit is contained in:
Wapaul1
2016-08-15 16:51:59 -07:00
committed by Philipp Moritz
parent b29fc0c481
commit 7246013008
11 changed files with 119 additions and 2 deletions
+18
View File
@@ -305,6 +305,24 @@ class APITest(unittest.TestCase):
ray.worker.cleanup()
def testSelect(self):
ray.init(start_ray_local=True, num_workers=4)
@ray.remote([float], [int])
def f(delay):
time.sleep(delay)
return 1
objectids = [f.remote(1.5), f.remote(1.5), f.remote(1.0), f.remote(0.5)]
self.assertEqual(ray.select(objectids), [])
time.sleep(0.75)
self.assertEqual(ray.select(objectids), [3])
time.sleep(0.5)
self.assertEqual(ray.select(objectids), [2, 3])
time.sleep(0.5)
self.assertEqual(ray.select(objectids), [0, 1, 2, 3])
ray.worker.cleanup()
def testCachingReusables(self):
# Test that we can define reusable variables before the driver is connected.
def foo_initializer():