stamina
Production-grade retries made easy.
What it is and what it does
Stamina is a retry library built on top of Tenacity that simplifies resilience patterns in distributed systems. It provides a decorator-based API that handles transient failures with exponential backoff, jitter, and configurable attempt and timeout limits. The library is designed to do the right thing by default—retrying only specified exceptions, respecting both attempt counts and total time budgets, and automatically supporting async functions including Trio.
The package includes first-class support for instrumentation via Prometheus, structlog, and standard logging, plus dedicated testing utilities to globally disable or limit retries during test runs. Type hints are preserved on decorated functions, and the same API works for both sync and async callables as well as arbitrary code blocks, making it suitable for I/O-heavy workloads where transient failures are common.
Use it for:
- Decorate functions to automatically retry on transient errors with exponential backoff and jitter.
- Retry async functions with the same API as sync functions, including Trio support.
- Instrument retry behavior with Prometheus metrics or structured logging for observability.
- Globally disable retries in test suites or limit retry attempts to speed up test execution.
- Configure both attempt count and total timeout limits to bound retry behavior.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Stamina wraps Tenacity to provide a production-ready retry decorator with sensible defaults: exponential backoff with jitter, attempt and timeout limits, exception filtering, and built-in async support for asyncio and Trio.
Yes. Stamina is actively maintained with no known vulnerabilities and low install friction. It solves a real problem—production-grade retries—with sensible defaults and a clean API. Use it when you need resilience in distributed systems and want to avoid copy-pasting retry logic.
Install
stamina on PyPI
pip
pip install staminauv
uv add staminapoetry
poetry add staminaInstalling stamina
Before you install
Low install friction; pure Python wheel with a single runtime dependency (tenacity). Actively maintained with recent commits and 1440 GitHub stars. Supports Python 3.10 through 3.14.
License in practice
MIT license (permissive) allows use in commercial and proprietary projects with minimal restrictions; attribution required but no copyleft obligations.
Quickstart
pip install stamina
import stamina
@stamina.retry(on=Exception, attempts=3)
def do_it():
pass
Requires Python 3.10 or later.
Verify before relying
- Whether Prometheus instrumentation requires additional dependencies beyond tenacity.
- How structlog integration behaves when structlog is not installed.
- Performance overhead of retry instrumentation in high-throughput scenarios.
- Specific exception types and filtering capabilities beyond what the description excerpt shows.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tenacity |
| Maintenance | actively maintained — 123 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,786,245/month — #2,037 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: stamina-26.1.0-py3-none-any.whl
Keywords: reliability, retries, retry
Tags
More Distributed Computing packages
gRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
smart-openProvides a unified, open()-compatible Python…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
tenacityTenacity is a retry library that adds automatic…
permissive · top 100 on PyPI
reretryA decorator and function wrapper for retrying…
permissive · top 15,000 on PyPI
retryhttpRetryhttp wraps HTTP client calls to…
permissive · top 5,000 on PyPI
justbackoffImplements exponential backoff with optional…
permissive · top 15,000 on PyPI
backoffProvides function decorators to automatically…
permissive · top 1,000 on PyPI
retry2Provides a decorator and function wrapper to…
permissive · top 5,000 on PyPI
python-backoffProvides function decorators for retrying…
permissive · top 5,000 on PyPI
robust-downloaderProvides resumable downloads with retry logic,…
permissive · top 5,000 on PyPI
retryingRetrying is a decorator-based library that adds…
permissive · top 1,000 on PyPI
retry-requestsWraps requests Session objects to automatically…
copyleft · top 15,000 on PyPI