pyrelukko.decorators module¶
Module with decorators used in pyrelukko.
- pyrelukko.decorators.retry(logger, exceptions, tries=4, delay=5, backoff=2.0, max_delay=None)¶
Retry calling the decorated function using an exponential backoff.
See https://www.calazan.com/retry-decorator-for-python-3/
- Parameters:
logger (Logger) – Python logger that supports
warning().exceptions (Exception|Tuple[Exception, Exception]) – The exception to catch and retry the decorated function again. May be a tuple of exceptions to catch.
tries (int, optional) – Number of times to try (not retry) before giving up, defaults to 4.
delay (int, optional) – Initial delay between retries in seconds, defaults to 5.
backoff (float, optional) – Backoff multiplier (e.g. value of 2 will double the delay with each retry), defaults to 2.0.
max_delay (int|float, optional) – The maximum value the delay between retries can grow, defaults to None.
- pyrelukko.decorators.skip_http_call()¶
Decorator for pyrelukko methods to skip HTTP calls.
It skips the actual method if the environment variable
RELUKKO_TRUST_ME_IT_IS_LOCKEDis set and returns instead a static lock dictionary or list with the same static lock dictionary.Useful when developing and the resource is for sure locked, e.g through the Web UI.