Reconstruct failed actors without sending tasks. (#5161)

* fast reconstruct dead actors

* add test

* fix typos

* remove debug print

* small fix

* fix typos

* Update test_actor.py
This commit is contained in:
Hao Chen
2019-07-16 01:25:09 +08:00
committed by Stephanie Wang
parent 7342117710
commit ea6aa6409a
3 changed files with 67 additions and 2 deletions
+22
View File
@@ -94,3 +94,25 @@ def wait_for_errors(error_type, num_errors, timeout=10):
return
time.sleep(0.1)
raise Exception("Timing out of wait.")
def wait_for_condition(condition_predictor,
timeout_ms=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.
retry_interval_ms: Retry interval in milliseconds.
Return:
Whether the condition is met within the timeout.
"""
time_elapsed = 0
while time_elapsed <= timeout_ms:
if condition_predictor():
return True
time_elapsed += retry_interval_ms
time.sleep(retry_interval_ms / 1000.0)
return False