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 = Field(True, description='Whether to retry requests.')
class-attribute
instance-attribute
exception = Field(RETRY_ERRORS, description='Exception(s) to catch and retry on.')
class-attribute
instance-attribute
max_tries = Field(default=None, gt=0, description='Maximum number of tries before giving up.')
class-attribute
instance-attribute
max_time = Field(default=60, ge=0, description='Maximum number of seconds to retry for.')
class-attribute
instance-attribute
wait_gen = Field(default=backoff.expo, description='Function that generates wait times.')
class-attribute
instance-attribute
jitter = Field(default=backoff.full_jitter, description='Function that jitters wait times.')
class-attribute
instance-attribute
giveup = Field(default=DEFAULT_PREDICATE, description='Predicate function that determines if we should give up.')
class-attribute
instance-attribute
on_success = Field(default=None, description='Function(s) to call on success.')
class-attribute
instance-attribute
on_backoff = Field(default=None, description='Function(s) to call when backing off.')
class-attribute
instance-attribute
on_giveup = Field(default=None, description='Function(s) to call when giving up.')
class-attribute
instance-attribute
raise_on_giveup = 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
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
instance-attribute
args
instance-attribute
kwargs
instance-attribute
tries
instance-attribute
elapsed
instance-attribute
Details
Bases: _Details