def __init__(self, retry_object, fn, args, kwargs): #: Retry call start timestamp self.start_time = _utils.now() #: Retry manager object self.retry_object = retry_object #: Function wrapped by this retry call self.fn = fn #: Arguments of the function wrapped by this retry call self.args = args #: Keyword arguments of the function wrapped by this retry call self.kwargs = kwargs #: The number of the current attempt self.attempt_number = 1 #: Last outcome (result or exception) produced by the function self.outcome = None #: Timestamp of the last outcome self.outcome_timestamp = None #: Time spent sleeping in retries self.idle_for = 0 #: Next action as decided by the retry manager self.next_action = None
def set_exception(self, exc_info): ts = _utils.now() fut = Future(self.attempt_number) _utils.capture(fut, exc_info) self.outcome, self.outcome_timestamp = fut, ts
def set_result(self, val): ts = _utils.now() fut = Future(self.attempt_number) fut.set_result(val) self.outcome, self.outcome_timestamp = fut, ts
def begin(self, fn): self.statistics.clear() self.statistics["start_time"] = _utils.now() self.statistics["attempt_number"] = 1 self.statistics["idle_for"] = 0 self.fn = fn