{"id":13472661,"url":"https://github.com/hynek/stamina","last_synced_at":"2025-04-29T14:39:46.636Z","repository":{"id":60561264,"uuid":"543711697","full_name":"hynek/stamina","owner":"hynek","description":"Production-grade retries for Python","archived":false,"fork":false,"pushed_at":"2025-04-07T17:54:53.000Z","size":936,"stargazers_count":1127,"open_issues_count":0,"forks_count":12,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-10T13:25:03.527Z","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","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"hynek","tidelift":"pypi/stamina"}},"created_at":"2022-09-30T17:23:17.000Z","updated_at":"2025-04-09T23:15:47.000Z","dependencies_parsed_at":"2023-10-03T13:35:10.436Z","dependency_job_id":"33801932-31b0-4363-8df9-0e43d21027c2","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":10,"template":false,"template_full_name":null,"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","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251520503,"owners_count":21602518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-04-29T14:39:46.614Z","avatar_url":"https://github.com/hynek.png","language":"Python","funding_links":["https://github.com/sponsors/hynek","https://tidelift.com/funding/github/pypi/stamina","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[![PyPI - Version](https://img.shields.io/pypi/v/stamina.svg)](https://pypi.org/project/stamina)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/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 predicate.\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 httpx\n\nimport stamina\n\n\n@stamina.retry(on=httpx.HTTPError, attempts=3)\ndef do_it(code: int) -\u003e httpx.Response:\n    resp = httpx.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"}