Tenacity

9.1.4 · active · verified Sat Mar 28

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

Install

Imports

Quickstart

A simple example demonstrating the use of Tenacity to retry a function that may raise an IOError.

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())

view raw JSON →