Easy mode for Tenacity.
Project description
stamina
Transient failures are common in distributed systems.
To deal with them, you need to retry failed operations.
Tenacity is an amazing and beautifully composable toolkit for handling retries that I've been using it for years.
In practice, I've found myself to use only very few knobs and wished it wouldn't erase the types of the callables that I decorate with @tenacity.retry
.
stamina is an opinionated thin layer around Tenacity that I've been copy-pasting between my projects for a long time:
- Retry only on certain exceptions.
- Exponential backoff with jitter between retries.
- Limit the number of retries and total time.
- Preserve type hints of the decorated callable.
- Count (Prometheus) and log (structlog) retries with basic metadata (if they're installed).
- Easy deactivation for testing.
Release Information
Added
- Retries are now instrumented.
If prometheus-client is installed, retries are counted using the Prometheus counter
stamina_retries_total
. If structlog is installed, they are logged using a structlog logger at warning level. These two instrumentations are independent from each other.
License
stamina is written by Hynek Schlawack and distributed under the terms of the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stamina-22.2.0.tar.gz
(12.6 kB
view hashes)