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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stamina-22.2.0.tar.gz
.
File metadata
- Download URL: stamina-22.2.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
77c370c82b6ced13617d42e1b93032fdb1435720db964e6d40f4b9f8746bfb7c
|
|
MD5 |
6849a411ff93513a5117c632606ee59e
|
|
BLAKE2b-256 |
9936be63373747885f8aff9220e71d0496456bae4d74bd29d9760c6895d5ef4e
|
File details
Details for the file stamina-22.2.0-py3-none-any.whl
.
File metadata
- Download URL: stamina-22.2.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d51df54359e0176efd86a04a08e68a7a9cdee5245499313feb3061009d624a30
|
|
MD5 |
a05e0fceac85a2f65b07bd1b986e4bc9
|
|
BLAKE2b-256 |
7cea04537875bbb02224212312d451585e1834a90c1bb75a84b93e62d9e32917
|