This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(1,40): | |
ready, not_ready = ray.wait(ids) | |
print('iteration:', i) | |
print('Ready length, values: ', len(ready), ray.get(ready)) | |
print('Not Ready length:', len(not_ready)) | |
ids = not_ready | |
if not ids: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = [busy.remote(i) for i in times] # New set of ids | |
for i in range(1,40): | |
ready, not_ready = ray.wait(ids, num_returns = 2) | |
print('iteration:', i) | |
print('Ready length, values: ', len(ready), ray.get(ready)) | |
print('Not Ready length:', len(not_ready)) | |
ids = not_ready | |
if not ids: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iteration: 1 | |
Ready length, values: 2 [5, 10] | |
Not Ready length: 3 | |
iteration: 2 | |
Ready length, values: 2 [15, 20] | |
Not Ready length: 1 | |
--------------------------------------------------------------------------- | |
Exception Traceback (most recent call last) | |
<ipython-input-7-a3a41a1b0002> in <module> | |
1 ids = [busy.remote(i) for i in times] # New set of ids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = [busy.remote(i) for i in times] # New set of ids | |
for i in range(1,40): | |
num_returns = 2 if len(ids) >= 2 else len(ids) | |
ready, not_ready = ray.wait(ids, num_returns = num_returns) | |
print('iteration:', i) | |
print('Ready length, values: ', len(ready), ray.get(ready)) | |
print('Not Ready length:', len(not_ready)) | |
ids = not_ready | |
if not ids: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = [busy.remote(i) for i in times] # New set of ids | |
for i in range(1,40): | |
num_returns = 2 if len(ids) >= 2 else len(ids) | |
ready, not_ready = ray.wait(ids, num_returns = num_returns, timeout = 2.5) | |
print('iteration:', i) | |
print('Ready length, values: ', len(ready), ray.get(ready)) | |
print('Not Ready length:', len(not_ready)) | |
ids = not_ready | |
if not ids: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = [busy.remote(0) for i in times] # New set of ids, but now 0 is passed to busy in all cases | |
for i in range(1,40): | |
num_returns = 2 if len(ids) >= 2 else len(ids) | |
ready, not_ready = ray.wait(ids, num_returns = num_returns) | |
print('iteration:', i) | |
print('Ready length, values: ', len(ready), ray.get(ready)) | |
print('Not Ready length:', len(not_ready)) | |
ids = not_ready | |
if not ids: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ray, time | |
ray.init() | |
# A function that "stays busy" for some number of seconds | |
def busy(i): | |
time.sleep(i) | |
return i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = time.time() | |
objs = [(i, busy(1.0)) for i in range(5)] | |
print('duration: %6.3f seconds' % (time.time() - start)) | |
for i,obj in list(objs): | |
print(f'{i}: {obj}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ray.remote | |
def rbusy(i): | |
return busy(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = time.time() | |
objs = [(i, ray.get(rbusy.remote(1.0)), time.time() - start) for i in range(5)] | |
end = time.time() - start | |
print('duration: %6.3f seconds' % (time.time() - start)) | |
for i,obj,t in list(objs): | |
print('%d: %s (time: %6.3f seconds)' % (i, obj, t)) |