Beispiel #1
0
def wait_for(check_func,
             error_message='Timed out waiting for completion',
             timeout=10):
    """
    Wait until web engine page loaded
    :return boolean: True on success, False on timeout
    """
    # Timeout in 10 seconds
    end_time = time.time() + timeout
    app = Registry().get('application')
    success = True
    while not check_func():
        now = time.time()
        if now > end_time:
            log.error(error_message)
            success = False
            break
        time.sleep(0.001)
        app.process_events()
    return success