harborapi.retry
RETRY_ERRORS = (TimeoutException, NetworkError)
module-attribute
P = ParamSpec('P')
module-attribute
T = TypeVar('T')
module-attribute
RetrySettings
Bases: BaseModel
Source code in harborapi/retry.py
enabled: bool = Field(True, description='Whether to retry requests.')
class-attribute
instance-attribute
exception: Union[Type[Exception], Tuple[Type[Exception], ...]] = Field(RETRY_ERRORS, description='Exception(s) to catch and retry on.')
class-attribute
instance-attribute
max_tries: Optional[int] = Field(default=None, gt=0, description='Maximum number of tries before giving up.')
class-attribute
instance-attribute
max_time: Optional[float] = Field(default=60, ge=0, description='Maximum number of seconds to retry for.')
class-attribute
instance-attribute
wait_gen: _WaitGenerator = Field(default=backoff.expo, description='Function that generates wait times.')
class-attribute
instance-attribute
jitter: Union[_Jitterer, None] = Field(default=backoff.full_jitter, description='Function that jitters wait times.')
class-attribute
instance-attribute
giveup: _Predicate[Exception] = Field(default=DEFAULT_PREDICATE, description='Predicate function that determines if we should give up.')
class-attribute
instance-attribute
on_success: Union[_Handler, Iterable[_Handler], None] = Field(default=None, description='Function(s) to call on success.')
class-attribute
instance-attribute
on_backoff: Union[_Handler, Iterable[_Handler], None] = Field(default=None, description='Function(s) to call when backing off.')
class-attribute
instance-attribute
on_giveup: Union[_Handler, Iterable[_Handler], None] = Field(default=None, description='Function(s) to call when giving up.')
class-attribute
instance-attribute
raise_on_giveup: bool = Field(default=True, description='Whether to raise the exception when giving up.')
class-attribute
instance-attribute
model_config = ConfigDict(extra='allow', validate_assignment=True)
class-attribute
instance-attribute
wait_gen_kwargs: Dict[str, Any]
property
Dict of extra model fields.
DEFAULT_PREDICATE(e)
get_backoff_kwargs(client)
Source code in harborapi/retry.py
retry()
Adds retry functionality to a HarborAsyncClient method.
NOTE: will fail if applied to any other class than HarborAsyncClient.
Source code in harborapi/retry.py
Backoff types
The following types come from the backoff package. They are documented here for convenience.
_CallableT = TypeVar('_CallableT', bound=Callable[..., Any])
module-attribute
_Handler = Union[Callable[[Details], None], Callable[[Details], Coroutine[Any, Any, None]]]
module-attribute
_Jitterer = Callable[[float], float]
module-attribute
_MaybeCallable = Union[T, Callable[[], T]]
module-attribute
_MaybeLogger = Union[str, logging.Logger, None]
module-attribute
_MaybeSequence = Union[T, Sequence[T]]
module-attribute
_WaitGenerator = Callable[..., Generator[float, None, None]]
module-attribute
_Details
Bases: TypedDict
target: Callable[..., Any]
instance-attribute
args: Tuple[Any, ...]
instance-attribute
kwargs: Dict[str, Any]
instance-attribute
tries: int
instance-attribute
elapsed: float
instance-attribute
Details
Bases: _Details