Stamina
Production-grade retries for Python
Install / Use
/learn @hynek/StaminaREADME
stamina: Production-grade Retries Made Easy
Transient failures are common in distributed systems. To make your systems resilient, you need to retry failed operations. But bad retries can make things much worse.
stamina is an opinionated wrapper around the great-but-unopinionated Tenacity package. Our goal is to be as ergonomic as possible, while doing the right thing by default, and minimizing the potential for misuse. It is the result of years of copy-pasting the same configuration over and over again:
- Retry only on certain exceptions – or even a subset of them by introspecting them first using a backoff hook.
- Exponential backoff with jitter between retries.
- Limit the number of retries and total time.
- Automatic async support – including Trio.
- Preserve type hints of the decorated callable.
- Flexible instrumentation with Prometheus, structlog, and standard library's
loggingsupport out-of-the-box. - Dedicated support for testing that allows to globally deactivate retries, or to limit the number of retries and to remove backoffs.
For example:
import httpx
import stamina
@stamina.retry(on=httpx.HTTPError, attempts=3)
def do_it(code: int) -> httpx.Response:
resp = httpx.get(f"https://httpbin.org/status/{code}")
resp.raise_for_status()
return resp
<!-- end docs index -->
Async callables work use the same API and it's possible to retry arbitrary blocks, too. Check out our tutorial for more examples!
Or, if you prefer video, here's a brief introduction into retries and stamina:

Project Links
Credits
stamina is written by Hynek Schlawack and distributed under the terms of the MIT license.
The development is kindly supported by my employer Variomedia AG and all my amazing GitHub Sponsors.
This project would not be possible without the years of incredible work that went into Tenacity.
stamina for Enterprise
Available as part of the Tidelift Subscription.
The maintainers of stamina and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open-source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.
Related Skills
node-connect
333.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
82.0kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
82.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
333.7kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
