{"id":13472661,"url":"https://github.com/hynek/stamina","last_synced_at":"2026-10-19T13:02:28.321Z","repository":{"id":60561264,"uuid":"543711697","full_name":"hynek/stamina","owner":"hynek","description":"Production-grade retries for Python","archived":false,"fork":false,"pushed_at":"2026-10-13T13:00:11.000Z","size":1051,"stargazers_count":1460,"open_issues_count":3,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-10-13T13:52:29.115Z","etag":null,"topics":["python","reliability","retry","retrying"],"latest_commit_sha":null,"homepage":"https://stamina.hynek.me/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hynek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","accessibility":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"claude":null,"gemini":null,"cursor":null,"copilot":null,"dco":null,"cla":null,"disclosure":null},"funding":{"github":"hynek","tidelift":"pypi/stamina","thanks_dev":"u/gh/hynek","custom":"https://hynek.me/say-thanks/"}},"created_at":"2022-09-30T17:23:17.000Z","updated_at":"2026-10-13T11:59:57.000Z","dependencies_parsed_at":"2026-10-13T13:34:54.198Z","dependency_job_id":null,"html_url":"https://github.com/hynek/stamina","commit_stats":{"total_commits":294,"total_committers":5,"mean_commits":58.8,"dds":0.06462585034013602,"last_synced_commit":"9fbfe4ea1588e5096d15b480b29e112a0994bd62"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/hynek/stamina","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hynek%2Fstamina","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hynek%2Fstamina/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hynek%2Fstamina/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hynek%2Fstamina/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hynek","download_url":"https://codeload.github.com/hynek/stamina/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hynek%2Fstamina/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38356506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-19T02:00:06.414Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","reliability","retry","retrying"],"created_at":"2024-07-31T16:00:56.876Z","updated_at":"2026-10-19T13:02:28.312Z","avatar_url":"https://github.com/hynek.png","language":"Python","funding_links":["https://github.com/sponsors/hynek","https://tidelift.com/funding/github/pypi/stamina","https://thanks.dev/u/gh/hynek","https://hynek.me/say-thanks/","https://tidelift.com/?utm_source=lifter\u0026utm_medium=referral\u0026utm_campaign=hynek"],"categories":["Python"],"sub_categories":[],"readme":"# *stamina*: Production-grade Retries Made Easy\n\n[![Documentation at ReadTheDocs](https://img.shields.io/badge/Docs-Read%20The%20Docs-black)](https://stamina.hynek.me)\n[![License: MIT](https://img.shields.io/badge/license-MIT-C06524)](https://github.com/hynek/stamina/blob/main/LICENSE)\n[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7550/badge)](https://bestpractices.coreinfrastructure.org/projects/7550)\n[![No AI slop inside.](https://img.shields.io/badge/no-slop-purple)](https://github.com/hynek/structlog/blob/main/.github/AI_POLICY.md)\n[![PyPI - Version](https://img.shields.io/pypi/v/stamina.svg)](https://pypi.org/project/stamina)\n[![Downloads](https://static.pepy.tech/badge/stamina/month)](https://pepy.tech/project/stamina)\n\n---\n\nTransient failures are common in distributed systems.\nTo make your systems resilient, you need to **retry** failed operations.\nBut bad retries can make things *much worse*.\n\n*stamina* is an opinionated wrapper around the great-but-unopinionated [Tenacity](https://tenacity.readthedocs.io/) package.\nOur goal is to be as **ergonomic** as possible, while doing the **right thing by default**, and minimizing the potential for **misuse**.\nIt is the result of years of copy-pasting the same configuration over and over again:\n\n- Retry only on certain exceptions – or even a subset of them by introspecting them first using a backoff hook.\n- Exponential **backoff** with **jitter** between retries.\n- Limit the number of retries **and** total time.\n- Automatic **async** support – including [Trio](https://trio.readthedocs.io/).\n- Preserve **type hints** of the decorated callable.\n- Flexible **instrumentation** with [Prometheus](https://github.com/prometheus/client_python), [*structlog*](https://www.structlog.org/), and standard library's `logging` support out-of-the-box.\n- Dedicated support for **testing** that allows to _globally_ deactivate retries, or to limit the number of retries and to remove backoffs.\n\nFor example:\n\n```python\nimport httpx2\n\nimport stamina\n\n\n@stamina.retry(on=httpx2.HTTPError, attempts=3)\ndef do_it(code: int) -\u003e httpx2.Response:\n    resp = httpx2.get(f\"https://httpbin.org/status/{code}\")\n    resp.raise_for_status()\n\n    return resp\n```\n\n\u003c!-- end docs index --\u003e\n\n**Async** callables work use the same API and it's possible to retry **arbitrary blocks**, too.\nCheck out our [tutorial](https://stamina.hynek.me/en/latest/tutorial.html) for more examples!\n\nOr, if you prefer video, here's a brief introduction into retries and *stamina*:\n[![Watch the video](https://img.youtube.com/vi/BxikFuvaT1Y/maxresdefault.jpg)](https://youtu.be/BxikFuvaT1Y)\n\n\n## Project Links\n\n- [**PyPI**](https://pypi.org/project/stamina/)\n- [**GitHub**](https://github.com/hynek/stamina)\n- [**Documentation**](https://stamina.hynek.me)\n- [**Changelog**](https://github.com/hynek/stamina/blob/main/CHANGELOG.md)\n- [**Funding**](https://hynek.me/say-thanks/)\n\n\n## Credits\n\n*stamina* is written by [Hynek Schlawack](https://hynek.me/) and distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\nThe development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/) and all my amazing [GitHub Sponsors](https://github.com/sponsors/hynek).\n\nThis project would not be possible without the years of incredible work that went into [Tenacity](https://tenacity.readthedocs.io/).\n\n\n## *stamina* for Enterprise\n\nAvailable as part of the [Tidelift Subscription](https://tidelift.com/?utm_source=lifter\u0026utm_medium=referral\u0026utm_campaign=hynek).\n\nThe 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.\nSave time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhynek%2Fstamina","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhynek%2Fstamina","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhynek%2Fstamina/lists"}