decorators¶
Decorators module.
- spicerack.decorators.get_effective_tries(params: wmflib.decorators.RetryParams, func: collections.abc.Callable, args: tuple, kwargs: dict) None [source]¶
Reduce the number of tries to use in the @retry decorator to one when the DRY-RUN mode is detected.
This is a callback function for the wmflib.decorators.retry decorator. The arguments are according to
wmflib.decorators.retry()
for thedynamic_params_callbacks
argument.- Parameters:
params (
wmflib.decorators.RetryParams
) -- the decorator original parameters.func (
collections.abc.Callable
) -- the decorated callable.args (
tuple
) -- the decorated callable positional arguments as tuple.kwargs (
dict
) -- the decorated callable keyword arguments as dictionary.
- Return type:
- spicerack.decorators.retry(*args: Any, **kwargs: Any) collections.abc.Callable [source]¶
Decorator to retry a function or method if it raises certain exceptions with customizable backoff.
A customized version of
wmflib.decorators.retry()
specific to Spicerack:If no exceptions to catch are specified use
spicerack.exceptions.SpicerackError
.Always append to the
dynamic_params_callbacks
parameter thespicerack.decorators.get_effective_tries()
function to force the tries parameter to 1 in DRY-RUN mode. Appending means that this callback will always be called for last, and eventually override any other modification of the tries parameter by other callbacks to 1 when in DRY-RUN mode.
For the arguments see
wmflib.decorators.retry()
.- Return type:
- Returns:
The decorated function.
- spicerack.decorators.set_tries(params: wmflib.decorators.RetryParams, func: collections.abc.Callable, _args: tuple, kwargs: dict) None [source]¶
Simple function to allow adapting the number of retries.
- Parameters:
params (
wmflib.decorators.RetryParams
) -- the decorator original parameters.func (
collections.abc.Callable
) -- the decorated callable._args (
tuple
) -- the decorated callable positional arguments as tuple. Unused.kwargs (
dict
) -- the decorated callable keyword arguments as dictionary.
- Return type: