import time


def await_condition(condition, timeout=2000):
    """Return True if a condition is met in the given timeout period"""

    for _ in range(timeout):
        if condition():
            return True
        time.sleep(0.001)
    return False