MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / wait_until

Function wait_until

tests/util.py:21–36  ·  view source on GitHub ↗

Executes a function at regular intervals while the condition is false and the amount of attempts < maxAttempts. :param condition: a function :param delay: the delay in second :param max_attempts: the maximum number of attempts. So the timeout of this fun

(condition, delay, max_attempts)

Source from the content-addressed store, hash-verified

19
20
21def wait_until(condition, delay, max_attempts):
22 """
23 Executes a function at regular intervals while the condition
24 is false and the amount of attempts < maxAttempts.
25 :param condition: a function
26 :param delay: the delay in second
27 :param max_attempts: the maximum number of attempts. So the timeout
28 of this function is delay*max_attempts
29 """
30 attempt = 0
31 while not condition() and attempt < max_attempts:
32 attempt += 1
33 time.sleep(delay)
34
35 if attempt >= max_attempts:
36 raise Exception("Condition is still False after {} attempts.".format(max_attempts))
37
38
39def wait_until_not_raised(condition, delay, max_attempts):

Callers 5

_test_all_datatypesMethod · 0.90
__test_udtMethod · 0.90
run_heartbeatMethod · 0.90

Calls 1

sleepMethod · 0.80

Tested by 5

_test_all_datatypesMethod · 0.72
__test_udtMethod · 0.72
run_heartbeatMethod · 0.72