Add failure tests to test_reference_counting (#7400)

This commit is contained in:
Edward Oakes
2020-03-17 10:30:21 -05:00
committed by GitHub
parent 7678418210
commit c1b0f9ccdf
10 changed files with 664 additions and 552 deletions
+3 -5
View File
@@ -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