---
id: tenacity
version: "9.1.4"
license: Apache 2.0
license_treatment: permissive
maintenance: active
---
# tenacity — Retry code until it succeeds
License: permissive · Maintenance: active · Popularity: top 100 on PyPI
## Install
pip install tenacity
uv add tenacity
poetry add tenacity
## Description
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 `_ **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
`_ which is sadly no longer
`maintained `_. 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...
## AI interpretation — verify before relying
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.
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.
[View on SkillFed](https://skillfed.io/packages/tenacity) · [View on PyPI](https://pypi.org/project/tenacity/)