Decorators module.

spicerack.decorators.get_effective_tries(params: wmflib.decorators.RetryParams, func: 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 the dynamic_params_callbacks argument.

  • params (wmflib.decorators.RetryParams) -- the decorator original parameters.

  • func (Callable) -- the decorated callable.

  • args (tuple) -- the decorated callable positional arguments as tuple.

  • kwargs (dict) -- the decorated callable keyword arguments as dictionary.

spicerack.decorators.retry(*args: Any, **kwargs: Any) 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 the spicerack.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().


the decorated function.

Return type