import time
from typing import Callable


def wait_for(func: Callable[[], bool], message: str, timeout: float = 5):
    current_time = time.time()
    end_time = current_time + timeout
    while current_time < end_time:
        if func():
            return
        time.sleep(0)
        current_time = time.time()

    raise RuntimeError(message)
