mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Implement select to enable waiting for a specific number of remote objects to be ready. (#369)
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user