Files
leleka/scripts/e2e/codex/tasks/debuglog-sched/seed/sched/retry.py
T

15 lines
435 B
Python

class RetryPolicy:
"""Exponential backoff with a cap."""
def __init__(self, max_attempts=3, base=2.0, factor=2.0, cap=30.0):
self.max_attempts = max_attempts
self.base = base
self.factor = factor
self.cap = cap
def delay(self, attempt):
return min(self.cap, self.base * self.factor ** (attempt - 1))
def exhausted(self, attempts):
return attempts >= self.max_attempts