Skip to content

Instantly share code, notes, and snippets.

@compwron compwron/
Last active Jan 3, 2020

What would you like to do?
demo of waiting for a condition
import time
from random import randint
def demo():
foo = randint(0, 100)
print(f"int is {foo}")
return foo % 5 == 0
def _wait_for(condition_func, interval=0.5, max_time=15):
started_at = time.time()
while time.time() < started_at + max_time:
done = condition_func()
if done:
print('we made it')
print('not yet')
print('It took too long so we stopped')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.