def retry_until_resource_is_consistent(func, monitor):
    """
    Runs func, if func raises DSResourceNotConsistentError will retry func indefinitely.
    Notifies monitor if we have to wait(only happens if DukeDS API raises DSResourceNotConsistentError.
    :param func: func(): function to run
    :param monitor: object: has start_waiting() and done_waiting() methods when waiting for non-consistent resource
    :return: whatever func returns
    """
    waiting = False
    while True:
        try:
            resp = func()
            if waiting and monitor:
                monitor.done_waiting()
            return resp
        except DSResourceNotConsistentError:
            if not waiting and monitor:
                monitor.start_waiting()
                waiting = True
            time.sleep(RESOURCE_NOT_CONSISTENT_RETRY_SECONDS)
Runs func, if func raises DSResourceNotConsistentError will retry func indefinitely.
    Notifies monitor if we have to wait(only happens if DukeDS API raises DSResourceNotConsistentError.
    :param func: func(): function to run
    :param monitor: object: has start_waiting() and done_waiting() methods when waiting for non-consistent resource
    :return: whatever func returns