mirror of
https://github.com/wassname/ray.git
synced 2026-07-03 15:27:36 +08:00
Add failure tests to test_reference_counting (#7400)
This commit is contained in:
@@ -137,24 +137,22 @@ def wait_for_errors(error_type, num_errors, timeout=20):
|
||||
|
||||
|
||||
def wait_for_condition(condition_predictor,
|
||||
timeout_ms=1000,
|
||||
timeout=1000,
|
||||
retry_interval_ms=100):
|
||||
"""A helper function that waits until a condition is met.
|
||||
|
||||
Args:
|
||||
condition_predictor: A function that predicts the condition.
|
||||
timeout_ms: Maximum timeout in milliseconds.
|
||||
timeout: Maximum timeout in seconds.
|
||||
retry_interval_ms: Retry interval in milliseconds.
|
||||
|
||||
Return:
|
||||
Whether the condition is met within the timeout.
|
||||
"""
|
||||
time_elapsed = 0
|
||||
start = time.time()
|
||||
while time_elapsed <= timeout_ms:
|
||||
while time.time() - start <= timeout:
|
||||
if condition_predictor():
|
||||
return True
|
||||
time_elapsed = (time.time() - start) * 1000
|
||||
time.sleep(retry_interval_ms / 1000.0)
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user