Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. import time
  2.  
  3. def wait_until(func, timeout, interval=0.25, *args, **kwargs):
  4. time_should_end = time.time() + timeout
  5. while time.time() < time_should_end:
  6. if func(*args, **kwargs):
  7. return True
  8. time.sleep(interval)
  9. raise TimeoutError(f'timed out while waiting for {func.__name__} to become true')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement