I was wondering if there was a sufficient way or a module to wait for a condition(function that returns bool), in given timeout? Example
def wait_for_condition(condition, timeout, interval) :
# implementation
# return True if the condition met in given timeout, else return False
Thanks in advance!
I would simply roll your own, this seems simple enough :
def wait_until(condition, interval=0.1, timeout=1, *args):
start = time.time()
while not condition(*args) and time.time() - start < timeout:
time.sleep(interval)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With