adp.core.retry.retry
- adp.core.retry.retry(exceptions: type[Exception] | ~typing.Tuple[type[Exception], ...] = <class 'Exception'>, tries: int = -1, delay: int = 0, max_delay: int | None = None, backoff: int = 1, jitter: float | ~typing.Tuple[float, float] = 0, on_exception: dict[type[Exception], ~typing.Callable[[Exception], tuple[int, ~typing.Any]]] | None = None)
Returns a retry decorator.
- Parameters:
exceptions – an exception or a tuple of exceptions to catch. default: Exception.
tries – the maximum number of attempts. default: -1 (infinite).
delay – initial delay between attempts. default: 0.
max_delay – the maximum value of delay. default: None (no limit).
backoff – multiplier applied to delay between attempts. default: 1 (no backoff).
jitter – extra seconds added to delay between attempts. default: 0. fixed if a number, random if a range tuple (min, max)
on_exception – a dictionary mapping exception types to functions to call when those exceptions occur. default: None.
- Returns:
a retry decorator.