(*args, **kwargs)
| 179 | def decorate(func): |
| 180 | @functools.wraps(func) |
| 181 | def wrapper(*args, **kwargs): |
| 182 | remaining_attempts = attempts |
| 183 | curr_delay = delay |
| 184 | while remaining_attempts > 0: |
| 185 | try: |
| 186 | return func(*args, **kwargs) |
| 187 | except Exception as err: |
| 188 | remaining_attempts -= 1 |
| 189 | last_exception = err |
| 190 | curr_delay *= backoff |
| 191 | if max_delay: |
| 192 | curr_delay = min(curr_delay, max_delay) |
| 193 | time.sleep(curr_delay) |
| 194 | raise last_exception |
| 195 | return wrapper |
| 196 | return decorate |
| 197 |