[docs]@dataclass(frozen=True)classRetryDetails:r""" Details about a retry attempt that are passed into :class:`RetryHook`\ s. Attributes: name: Name of the callable that is being retried. args: Positional arguments that were passed to the callable. kwargs: Keyword arguments that were passed to the callable. retry_num: Number of the retry attempt. Starts at 1 after the first failure. wait_for: Time in seconds that *stamina* will wait before the next attempt. waited_so_far: Time in seconds that *stamina* has waited so far for the current callable. caused_by: Exception that caused the retry attempt. .. versionadded:: 23.2.0 """__slots__=("args","caused_by","kwargs","name","retry_num","wait_for","waited_so_far",)name:strargs:tuple[object,...]kwargs:dict[str,object]retry_num:intwait_for:floatwaited_so_far:floatcaused_by:Exception
[docs]classRetryHook(Protocol):""" A callable that gets called after an attempt has failed and a retry has been scheduled. This is a :class:`typing.Protocol` that can be implemented by any callable that takes one argument of type :class:`RetryDetails` and returns None. If the hook returns a context manager, it will be entered when the retry is scheduled and exited right before the retry is attempted. .. versionadded:: 23.2.0 .. versionadded:: 25.1.0 Added support for context managers. """def__call__(self,details:RetryDetails)->None|AbstractContextManager[None]:...
[docs]@dataclass(frozen=True)classRetryHookFactory:""" Wraps a callable that returns a :class:`RetryHook`. They are called on the first scheduled retry and can be used to delay initialization. If you need to pass arguments, you can do that using :func:`functools.partial`. .. versionadded:: 23.2.0 """hook_factory:Callable[[],RetryHook]