def wait_until_passes(timeout, retry_interval, func, exceptions=Exception, *args, **kwargs):
    '\n    Wait until ``func(*args, **kwargs)`` does not raise one of the exceptions\n\n    * **timeout**  how long the function will try the function\n    * **retry_interval**  how long to wait between retries\n    * **func** the function that will be executed\n    * **exceptions**  list of exceptions to test against (default: Exception)\n    * **args** optional arguments to be passed to func when called\n    * **kwargs** optional keyword arguments to be passed to func when called\n\n    Returns the return value of the function\n    If the operation times out then the original exception raised is in\n    the \'original_exception\' attribute of the raised exception.\n\n    e.g. ::\n\n        try:\n            # wait a maximum of 10.5 seconds for the\n            # window to be found in increments of .5 of a second.\n            # P.int a message and re-raise the original exception if never found.\n            wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))\n        except TimeoutError as e:\n            print("timed out")\n            raise e.\n    '
    start = timestamp()
    while True:
        try:
            func_val = func(*args, **kwargs)
            break
        except exceptions as e:
            time_left = (timeout - (timestamp() - start))
            if (time_left > 0):
                time.sleep(min(retry_interval, time_left))
            else:
                err = TimeoutError()
                err.original_exception = e
                raise err
    return func_val
Wait until ``func(*args, **kwargs)`` does not raise one of the exceptions

* **timeout**  how long the function will try the function
* **retry_interval**  how long to wait between retries
* **func** the function that will be executed
* **exceptions**  list of exceptions to test against (default: Exception)
* **args** optional arguments to be passed to func when called
* **kwargs** optional keyword arguments to be passed to func when called

Returns the return value of the function
If the operation times out then the original exception raised is in
the 'original_exception' attribute of the raised exception.

e.g. ::

    try:
        # wait a maximum of 10.5 seconds for the
        # window to be found in increments of .5 of a second.
        # P.int a message and re-raise the original exception if never found.
        wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))
    except TimeoutError as e:
        print("timed out")
        raise e.
def wait_until_passes(timeout, retry_interval, func, exceptions=Exception, *args, **kwargs):
    '\n    Wait until ``func(*args, **kwargs)`` does not raise one of the exceptions\n\n    * **timeout**  how long the function will try the function\n    * **retry_interval**  how long to wait between retries\n    * **func** the function that will be executed\n    * **exceptions**  list of exceptions to test against (default: Exception)\n    * **args** optional arguments to be passed to func when called\n    * **kwargs** optional keyword arguments to be passed to func when called\n\n    Returns the return value of the function\n    If the operation times out then the original exception raised is in\n    the \'original_exception\' attribute of the raised exception.\n\n    e.g. ::\n\n        try:\n            # wait a maximum of 10.5 seconds for the\n            # window to be found in increments of .5 of a second.\n            # P.int a message and re-raise the original exception if never found.\n            wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))\n        except TimeoutError as e:\n            print("timed out")\n            raise e.\n    '
    start = timestamp()
    while True:
        try:
            func_val = func(*args, **kwargs)
            break
        except exceptions as e:
            time_left = (timeout - (timestamp() - start))
            if (time_left > 0):
                time.sleep(min(retry_interval, time_left))
            else:
                err = TimeoutError()
                err.original_exception = e
                raise err
    return func_val