skillfed

stamina

Production-grade retries made easy.

stamina v26.1.0 5.8M downloads/30d#2,037 on PyPI1,440
Permissive license MIT Active released

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 stamina

uv

uv add stamina

poetry

poetry add stamina

Installing 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

Development Status :: 5 - Production/StableFramework :: AsyncIOFramework :: TrioLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed

Tags

retry decorator with backoffexponential backoff retryasync retry libraryproduction retry handlingresilient distributed systemstransient failure retrytenacity wrapper
resilienceobservability

More Distributed Computing packages