예제 #1
0
    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
예제 #2
0
 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
예제 #3
0
 def set_result(self, val):
     ts = _utils.now()
     fut = Future(self.attempt_number)
     fut.set_result(val)
     self.outcome, self.outcome_timestamp = fut, ts
예제 #4
0
 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