Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ray.get(timeout=0) to throw timeout error #30210

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/ray/_private/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def get_objects(self, object_refs: list, timeout: Optional[float] = None):
"which is not an ray.ObjectRef."
)

timeout_ms = int(timeout * 1000) if timeout else -1
timeout_ms = int(timeout * 1000) if timeout is not None else -1
data_metadata_pairs = self.core_worker.get_objects(
object_refs, self.current_task_id, timeout_ms
)
Expand Down
4 changes: 4 additions & 0 deletions python/ray/tests/test_basic_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ def test_get_with_timeout(ray_start_regular_shared):
with pytest.raises(TimeoutError):
ray.get(result_id, timeout=0.1)

# timeout of 0 should raise an error
with pytest.raises(GetTimeoutError):
ray.get(result_id, timeout=0)

# Check that a subsequent get() returns early.
ray.get(signal.send.remote())
start = time.time()
Expand Down
6 changes: 3 additions & 3 deletions python/ray/tests/test_object_spilling.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def test_spill_objects_automatically(fs_only_object_spilling_config, shutdown_on
index = random.choice(list(range(buffer_length)))
ref = replay_buffer[index]
solution = solution_buffer[index]
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, solution)
assert_no_thrashing(address["address"])

Expand Down Expand Up @@ -359,7 +359,7 @@ def test_unstable_spill_objects_automatically(unstable_spilling_config, shutdown
index = random.choice(list(range(buffer_length)))
ref = replay_buffer[index]
solution = solution_buffer[index]
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, solution)
assert_no_thrashing(address["address"])

Expand Down Expand Up @@ -397,7 +397,7 @@ def test_slow_spill_objects_automatically(slow_spilling_config, shutdown_only):
index = random.choice(list(range(buffer_length)))
ref = replay_buffer[index]
solution = solution_buffer[index]
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, solution)
assert_no_thrashing(address["address"])

Expand Down
6 changes: 3 additions & 3 deletions python/ray/tests/test_object_spilling_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_delete_objects_delete_while_creating(object_spilling_config, shutdown_o
# Do random sampling.
for _ in range(200):
ref = random.choice(replay_buffer)
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, arr)

# After all, make sure all objects are killed without race condition.
Expand Down Expand Up @@ -126,7 +126,7 @@ def create_objects(self):
# Do random sampling.
for _ in range(200):
ref = random.choice(self.replay_buffer)
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, arr)

a = Actor.remote()
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_fusion_objects(fs_only_object_spilling_config, shutdown_only):
index = random.choice(list(range(buffer_length)))
ref = replay_buffer[index]
solution = solution_buffer[index]
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, solution)

is_test_passing = False
Expand Down
2 changes: 1 addition & 1 deletion python/ray/tests/test_object_spilling_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def test_spill_deadlock(object_spilling_config, shutdown_only):
if random.randint(0, 9) < 5:
for _ in range(5):
ref = random.choice(replay_buffer)
sample = ray.get(ref, timeout=0)
sample = ray.get(ref, timeout=None)
assert np.array_equal(sample, arr)
assert_no_thrashing(address["address"])

Expand Down