def _failover_read_request(request_fn, endpoint, path, body, params, timeout): """ This function auto-retries read-only requests until they return a 2xx status code. """ try: return request_fn("GET", endpoint, path, body, params, timeout) except (requests.exceptions.RequestException, Non200ResponseException) as ex: raise FailoverException(ex)
def my_failover_func(i, should_raise=None): """ Increments a counter and raises an exception when told. """ i.increment() if should_raise is not None: raise should_raise() raise FailoverException(FinishedException())