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.