Tenacity
Tenacity is a general-purpose retrying library for Python, designed to simplify adding retry behavior to functions. The current version is 9.1.4, released on February 7, 2026. It follows a regular release cadence, with recent updates addressing Python 3.14 support and improvements to retry annotations. ([pypi.org](https://pypi.org/project/tenacity/?utm_source=openai))
Warnings
- breaking Tenacity is a fork of the 'retrying' library and is not API compatible with it.
- gotcha Ensure 'retry' is imported from 'tenacity' to utilize its retrying capabilities.
Install
-
pip install tenacity
Imports
- retry
from tenacity import retry
Quickstart
import random
from tenacity import retry
@retry
def do_something_unreliable():
if random.randint(0, 10) > 1:
raise IOError('Broken sauce, everything is hosed!!!111one')
else:
return 'Awesome sauce!'
print(do_something_unreliable())