tenacity
Retry code until it succeeds
Install
tenacity on PyPI
pip
pip install tenacityuv
uv add tenacitypoetry
poetry add tenacityPackage facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 187 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the 100 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: tenacity-9.1.4-py3-none-any.whl
About tenacity
from the package's own PyPI description — quoted content, verbatim
Tenacity
.. image:: https://img.shields.io/pypi/v/tenacity.svg :target: https://pypi.org/project/tenacity
.. image:: https://img.shields.io/pypi/pyversions/tenacity.svg :target: https://pypi.org/project/tenacity
.. image:: https://github.com/jd/tenacity/actions/workflows/ci.yaml/badge.svg?branch=main :target: https://github.com/jd/tenacity/actions/workflows/ci.yaml
.. image:: https://img.shields.io/endpoint.svg?url=https://api.mergify.com/badges/jd/tenacity&style=flat :target: https://mergify.io :alt: Mergify Status
Please refer to the tenacity documentation <https://tenacity.readthedocs.io/en/latest/>_ for a better experience.
Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in
Python, to simplify the task of adding retry behavior to just about anything.
It originates from a fork of retrying
<https://github.com/rholder/retrying/issues/65> which is sadly no longer
maintained <https://julien.danjou.info/python-tenacity/>. Tenacity isn't
api compatible with retrying but adds significant new functionality and
fixes a number of longstanding bugs.
The simplest use case is retrying a flaky function whenever...
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
Tenacity is a general-purpose retrying library that simplifies adding retry logic to functions and code blocks with configurable stop conditions, wait strategies, and exception handling.
Installation is straightforward with no runtime dependencies. The package is actively maintained with recent releases and strong community adoption (top 100 PyPI), making it a reliable choice for production use.
Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Usage
pip install tenacity
from tenacity import retry, stop_after_attempt
@retry(stop=stop_after_attempt(3))
def unreliable_function():
# Function body that may fail
pass
result = unreliable_function()
Requires Python 3.10 or later.
Verdict: Tenacity is a well-maintained, zero-dependency retry library with permissive licensing and no known vulnerabilities. It's suitable for production use across current Python versions, offering flexible retry strategies via decorators and context managers.
Needs verification
- Whether async/await retry support is fully compatible with all Python 3.10+ async patterns
- Performance characteristics under high-frequency retry scenarios with exponential backoff
Similar packages
permissive · top 1,000 on PyPI
pytest-rerunfailurescopyleft · top 1,000 on PyPI
aiohttp-retrypermissive · top 1,000 on PyPI
retrypermissive · top 1,000 on PyPI
backoffpermissive · top 1,000 on PyPI
datadog-api-clientpermissive · top 1,000 on PyPI
azure-coreunclear · top 1,000 on PyPI
sse-starlettepermissive · top 1,000 on PyPI
tblibpermissive · top 1,000 on PyPI
pytest-json-ctrfpermissive · top 1,000 on PyPI