(self, fn, *args, **kwargs)
| 193 | return reject |
| 194 | |
| 195 | def call(self, fn, *args, **kwargs): |
| 196 | start_time = int(round(time.time() * 1000)) |
| 197 | attempt_number = 1 |
| 198 | while True: |
| 199 | try: |
| 200 | attempt = Attempt(fn(*args, **kwargs), attempt_number, False) |
| 201 | except: |
| 202 | tb = sys.exc_info() |
| 203 | attempt = Attempt(tb, attempt_number, True) |
| 204 | |
| 205 | if not self.should_reject(attempt): |
| 206 | return attempt.get(self._wrap_exception) |
| 207 | |
| 208 | delay_since_first_attempt_ms = int(round(time.time() * 1000)) - start_time |
| 209 | if self.stop(attempt_number, delay_since_first_attempt_ms): |
| 210 | if not self._wrap_exception and attempt.has_exception: |
| 211 | # get() on an attempt with an exception should cause it to be raised, but raise just in case |
| 212 | raise attempt.get() |
| 213 | else: |
| 214 | raise RetryError(attempt) |
| 215 | else: |
| 216 | sleep = self.wait(attempt_number, delay_since_first_attempt_ms) |
| 217 | if self._wait_jitter_max: |
| 218 | jitter = random.random() * self._wait_jitter_max |
| 219 | sleep = sleep + max(0, jitter) |
| 220 | time.sleep(sleep / 1000.0) |
| 221 | |
| 222 | attempt_number += 1 |
| 223 | |
| 224 | |
| 225 | class Attempt(object): |
no test coverage detected