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 the dynamic_params_callbacks argument.

Parameters:
Return type:

None

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 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().

Return type:

collections.abc.Callable

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:
Return type:

None