tenacity

A general-purpose Python retrying library that adds configurable retry behavior to almost anything

Library
PyPI
v9.1.4
8,750stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity84
Maintenance64
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
88/100Excellent
Architecture90
Code Quality88
Innovation88
Learning Curve85

Tenacity is an Apache 2.0 licensed, general-purpose retrying library for Python that makes it trivial to add resilient retry behavior to functions, coroutines, and arbitrary blocks of code. Originating as a maintained fork of the abandoned retrying library, it exposes a simple @retry decorator alongside a rich, composable vocabulary of stop, wait, and retry conditions.

Instead of scattering ad-hoc try/except loops throughout a codebase, developers declare retry policies declaratively: how many attempts to make, how long to wait between them, which exceptions or return values should trigger a retry, and what to do when retries are finally exhausted. This makes it a staple dependency for code that talks to flaky networks, remote APIs, and distributed services.

What You Get

  • A generic @retry decorator that works on plain functions, async coroutines, and Tornado coroutines
  • Composable stop conditions such as stop_after_attempt and stop_after_delay that combine with the | operator
  • A full family of wait strategies including fixed, random, and exponential backoff with jitter
  • Fine-grained retry predicates that react to specific exception types or to the returned result
  • Callbacks and logging hooks (before, after, before_sleep) plus per-call retry statistics

Common Use Cases

  • Retrying HTTP calls to remote APIs and microservices that fail intermittently
  • Adding exponential backoff with jitter when contending for shared or rate-limited resources
  • Waiting for eventually-consistent systems (databases, queues, cloud resources) to become ready
  • Hardening background jobs and data pipelines against transient network and I/O errors

Under The Hood

Architecture - Tenacity centers on a BaseRetrying engine (in tenacity/__init__.py) that drives an attempt loop, delegating three orthogonal decisions to pluggable strategy objects: stop conditions (tenacity/stop.py), wait strategies (tenacity/wait.py), and retry predicates (tenacity/retry.py). Each strategy is a small callable that receives a shared RetryCallState carrying attempt number, outcome future, and timing data; strategies compose via overloaded | and & operators into retry_any/retry_all trees. Synchronous execution flows through Retrying, while tenacity/asyncio/ provides an AsyncRetrying variant that awaits coroutine outcomes and sleeps, and tenacity/tornadoweb.py adapts the loop to Tornado coroutines.

Tech Stack - Pure Python (100% of the codebase) targeting Python 3.10+, with zero required runtime dependencies. It ships type hints and a py.typed marker for full typing support. The build uses Hatchling with hatch-vcs for git-tag-derived versioning. Development tooling includes pytest, mypy, ruff, poethepoet task running, Sphinx with reno for docs, and optional Tornado/trio/typeguard for testing async integrations.

Code Quality - The project is well tested, with an extensive tests/test_tenacity.py (130+ test functions) plus dedicated suites for asyncio, Tornado, utilities, and regression tests for specific issues. Code is fully type-annotated and mypy-checked, uses clear abstract base classes for each strategy family, and follows consistent naming (stop_*, wait_*, retry_if_*). Apache-2.0 license headers are present across source files.

API Design - The public API is a highlight: the bare @retry decorator works with zero configuration, while keyword arguments (stop, wait, retry, reraise, before_sleep) layer in behavior incrementally. Strategy objects read declaratively and combine with intuitive boolean operators, keeping call sites free of imperative loop boilerplate. Extensive ReadTheDocs documentation with doctest-verified examples makes the learning curve gentle for common cases while still exposing RetryCallState for advanced custom callbacks.

Used by 22 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
49%
Other

Airbyte

Developer Tools · Data Engineering

21,916

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python49%
Kotlin42%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
88%
Apache 2.0

ART

AI Development

10,603

Give your LLM agents on-the-job training—ART lets you apply GRPO reinforcement learning to any multi-step agentic workflow with minimal code changes.

View details
85
Repo Health
82
Technical
72
Dependency
Built with
Python88%
Cuda10%
Updated today
Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
TypeScript
48%
AGPL 3.0

Banana Slides

AI Design Tools · Productivity

15,476

AI-native PPT generator with Vibe editing, multi-LLM support, and fully editable PPTX export

View details
83
Repo Health
82
Technical
71
Dependency
Built with
TypeScript48%
Python47%
Updated 3 days ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

152,883

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
71
Dependency
Built with
TypeScript50%
Python47%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search