def METHOD_NAME():
    if os.environ.get("GITHUB_ACTIONS") == "true":
        # Avoid random timeouting errors
        default_timeout = 20
    else:
        # Short timeout is good for local development, so that you quickly notice something is wrong
        default_timeout = 4
    def actually_wait_until(condition, *, timeout=default_timeout):
        end = time.monotonic() + timeout
        while time.monotonic() < end:
            get_main_window().update()
            boolean = condition()
            assert isinstance(boolean, bool)  # https://github.com/Akuli/porcupine/issues/1095
            if boolean:
                return
        raise RuntimeError("timed out waiting")
    return actually_wait_until