# jd/tenacity

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jd-tenacity).**

8,375 stars · 306 forks · Python · apache-2.0

## Links

- GitHub: https://github.com/jd/tenacity
- Homepage: http://tenacity.readthedocs.io
- awesome-repositories: https://awesome-repositories.com/repository/jd-tenacity.md

## Topics

`failure` `hacktoberfest` `python` `retry` `retry-library`

## Description

Tenacity is a Python retry library and fault tolerance framework designed to automatically re-execute failing functions based on custom conditions, wait intervals, and stop criteria. It provides a mechanism to apply retry logic to both synchronous functions and asynchronous coroutines.

The library implements exponential backoff to increase delays between retries, helping to manage transient network failures and prevent the overloading of services.

Its capabilities cover the definition of retry conditions based on exception types or return values, as well as the enforcement of duration limits through maximum attempt counts or elapsed time. It also includes tools for monitoring reliability via retry statistics and custom callbacks.

## Tags

### DevOps & Infrastructure

- [Automatic Retry Mechanisms](https://awesome-repositories.com/f/devops-infrastructure/job-scheduling/automatic-retry-mechanisms.md) — Automatically re-executes failing functions or code blocks based on specified conditions for both synchronous and asynchronous calls. ([source](http://tenacity.readthedocs.io))
- [Resilient Application Patterns](https://awesome-repositories.com/f/devops-infrastructure/resilient-infrastructure/resilient-application-patterns.md) — Handles intermittent failures in code by automatically retrying functions until they succeed or a limit is reached.

### Software Engineering & Architecture

- [Fault Tolerance Implementation](https://awesome-repositories.com/f/software-engineering-architecture/fault-tolerance-strategies/fault-tolerance-implementation.md) — Implements a framework of decorators and objects to automate recovery from function failures through managed retries.
- [Retry Policies](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/retry-policies.md) — Enables triggering retries based on specific exception types, error messages, or function return values. ([source](http://tenacity.readthedocs.io))
- [Exception-Driven Control Flows](https://awesome-repositories.com/f/software-engineering-architecture/exception-raising-mechanisms/exception-driven-control-flows.md) — Uses caught exceptions to trigger the retry loop and raises the final error once limits are reached.
- [Function Decorators](https://awesome-repositories.com/f/software-engineering-architecture/higher-order-function-wrapping/function-decorators.md) — Implements retry logic using Python decorators to wrap target functions and manage execution loops.
- [Retry Policies](https://awesome-repositories.com/f/software-engineering-architecture/retry-policies.md) — Stops retries after a maximum number of attempts or a specific elapsed time. ([source](http://tenacity.readthedocs.io))
- [Backoff Strategies](https://awesome-repositories.com/f/software-engineering-architecture/retry-policies/backoff-strategies.md) — Implements exponential backoff to increase delays between retries and prevent overloading external services.
- [Error Recovery](https://awesome-repositories.com/f/software-engineering-architecture/error-recovery.md) — Tracks failure rates and attempt counts for critical operations to monitor system reliability.

### Development Tools & Productivity

- [Retry Wait Strategies](https://awesome-repositories.com/f/development-tools-productivity/duration-formatters/duration-interval-calculators/retry-wait-strategies.md) — Calculates the pause between attempts using strategies like exponential backoff and random jitter.

### Programming Languages & Runtimes

- [Asynchronous Task Retries](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/background-task-management/background-task-retry-policies/asynchronous-task-retries.md) — Implements automatic retry mechanisms for asynchronous coroutines to handle transient errors in concurrent workflows.
- [Retry Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/retry-libraries.md) — Provides a specialized library for automatic function re-execution with custom conditions and wait intervals.

### Web Development

- [Predicate-Based Error Filtering](https://awesome-repositories.com/f/web-development/error-handling/predicate-based-error-filtering.md) — Determines whether to retry by evaluating exceptions against specified types or custom boolean predicate functions.
- [Wait Interval Controllers](https://awesome-repositories.com/f/web-development/randomized-interval-schedulers/wait-interval-controllers.md) — Manages pauses between retries using fixed delays, random intervals, or exponential backoff. ([source](http://tenacity.readthedocs.io))
- [Retry and Backoff Logic](https://awesome-repositories.com/f/web-development/http-client-wrappers/retry-and-backoff-logic.md) — Manages unstable API calls or database connections using exponential backoff and specific retry conditions.

### Networking & Communication

- [System Stability Protections](https://awesome-repositories.com/f/networking-communication/traffic-management-gateways/system-stability-protections.md) — Prevents service overload during outages by controlling retry intervals and limiting execution duration.

### System Administration & Monitoring

- [Retry Metrics Monitoring](https://awesome-repositories.com/f/system-administration-monitoring/retry-metrics-monitoring.md) — Provides access to attempt counts and outcome data to monitor the reliability of retried functions. ([source](http://tenacity.readthedocs.io))
