tenacity
Retry code until it succeeds
Decision gist · record as of 2026-08-14
Yes. Tenacity is a mature, actively maintained library in the top 100 PyPI packages with no known vulnerabilities, zero runtime dependencies, and permissive licensing. It solves a common problem (adding retry logic) with a clean API and is suitable for production use.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low install friction with no runtime dependencies.
- Active maintenance with recent releases and 8746 repository stars.
License · maintenance · safety
Apache 2.0 (permissive) — Apache 2.0 permissive license allows use in commercial and proprietary projects with minimal restrictions.
last release 2026-02-07 (188 days) · last repo commit 2026-08-06 · 8,746 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 429,288,446 downloads/mo, #98 on PyPI
Alternatives
Verify before relying
pip install tenacity
from tenacity import retry, stop_after_attempt
@retry(stop=stop_after_attempt(3))
def do_something():
# function body
passWhat it is and what it does
Tenacity is a general-purpose retry library that simplifies adding retry behavior to functions and code blocks in Python. It originated as a maintained fork of an unmaintained library and provides a decorator-based API to automatically retry functions when exceptions occur or specific conditions are met.
The library supports flexible retry strategies including configurable stop conditions (attempt limits, time limits), wait strategies (fixed delays, exponential backoff, jitter, chained backoffs), and fine-grained control over which exceptions or return values trigger retries. It works with regular functions, coroutines, and context managers, making it applicable across synchronous and asynchronous code patterns.
Use it for
- Retry flaky network requests or API calls with exponential backoff to handle transient failures.
- Implement resilience in distributed systems by retrying remote service calls with configurable delays.
- Handle database connection timeouts or temporary unavailability with bounded retry attempts.
- Add retry logic to file I/O operations that may fail due to temporary resource contention.
- Build fault-tolerant batch jobs that retry individual task failures before giving up.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Tenacity is a mature, actively maintained library in the top 100 PyPI packages with no known vulnerabilities, zero runtime dependencies, and permissive licensing. It solves a common problem (adding retry logic) with a clean API and is suitable for production use.
Install
tenacity on PyPI
Before you install
Low install friction with no runtime dependencies. Active maintenance with recent releases and 8746 repository stars. Supports current Python versions (3.10 through 3.14).
Requires Python 3.10 or later.
License in practice
Apache 2.0 permissive license allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install tenacity
from tenacity import retry, stop_after_attempt
@retry(stop=stop_after_attempt(3))
def do_something():
# function body
pass
Package 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 188 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 429,288,446 / month, #98 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Utilities |
Evidence: tenacity-9.1.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “flaky function resilience”
- tenacityTenacity is a retry library that adds automatic retry behavior to…
- httpx-retriesAdds automatic request retry logic to HTTPX, with configurable…
- pytest-retrypytest-retry is a pytest plugin that automatically retries failed…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also retryhttp · retrying · stamina · python-retry · robust-downloader · reretry · retry · retry2 · redo · backoff