je_load_density.utils.reliability.adaptive_retry
Adaptive retry with exponential backoff, jitter, and per-error-class budgets.
The policy classifies an exception into one of three buckets:
transient— retry liberally (default 5×).flaky— retry sparingly (default 2×).permanent— do not retry; the error is the answer.
run_with_retry(fn, policy=...) wraps a callable. Callers can also
classify their own exception types by passing classifier= to
AdaptiveRetryPolicy.
Functions
|
|
|
Run |
Classes
|
|
|
- class je_load_density.utils.reliability.adaptive_retry.AdaptiveRetryPolicy(transient_budget: int = 5, flaky_budget: int = 2, permanent_budget: int = 0, base_delay: float = 0.1, max_delay: float = 5.0, backoff_factor: float = 2.0, jitter: float = 0.25, classifier: Callable[[BaseException], str] = <function classify_error at 0x711192324860>, _counts: Dict[str, int] = <factory>)
Bases:
object- backoff_factor: float = 2.0
- base_delay: float = 0.1
- budget_for(classification: str) int
- classifier() str
- decide(error: BaseException, attempt: int) RetryDecision
- flaky_budget: int = 2
- jitter: float = 0.25
- max_delay: float = 5.0
- permanent_budget: int = 0
- reset() None
- transient_budget: int = 5
- class je_load_density.utils.reliability.adaptive_retry.RetryDecision(attempt: int, classification: str, delay_seconds: float, will_retry: bool)
Bases:
object- attempt: int
- classification: str
- delay_seconds: float
- will_retry: bool
- je_load_density.utils.reliability.adaptive_retry.classify_error(error: BaseException) str
- je_load_density.utils.reliability.adaptive_retry.run_with_retry(fn: ~typing.Callable[[], object], policy: ~je_load_density.utils.reliability.adaptive_retry.AdaptiveRetryPolicy | None = None, sleeper: ~typing.Callable[[float], None] = <built-in function sleep>) object
Run
fnunderpolicy. Returnsfn’s result on success; re-raises the last exception once the budget is exhausted.