retry2
Easy to use retry decorator.
What it is and what it does
retry2 is a decorator-based retry library that wraps function calls to automatically re-execute them when they fail with specified exceptions. It lets you configure the number of attempts, delay between retries, exponential backoff multipliers, random jitter, and optional logging of failures. The package is a maintained fork of an unmaintained original and aims to keep retry logic simple and dependency-light.
You use it by decorating a function with @retry() and specifying which exceptions to catch, how many times to try, and how long to wait between attempts. It also provides a retry_call() function for cases where you need to apply retry logic dynamically rather than at definition time. The library preserves original tracebacks for debugging and can optionally use decorator to preserve function signatures.
Use it for:
- Wrap API calls to handle transient network failures with exponential backoff.
- Retry database operations that may fail due to temporary locks or connection issues.
- Implement resilience in web scraping or data-fetching tasks with configurable delays.
- Add retry logic to background jobs or scheduled tasks without rewriting the function.
- Dynamically adjust retry behavior at runtime using retry_call() based on application state.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a decorator and function wrapper to automatically retry failed function calls with configurable delays, backoff, and exception handling.
Yes, if you need straightforward retry logic with minimal dependencies. The low install friction, permissive license, and zero known vulnerabilities make it safe to adopt. However, the dormant maintenance status (last release 2023-01-11) means you should verify it handles your specific exception types and retry patterns before relying on it in production.
Install
retry2 on PyPI
pip
pip install retry2uv
uv add retry2poetry
poetry add retry2Installing retry2
Before you install
Low friction: pure Python wheel with a single optional runtime dependency (decorator). Maintenance is dormant—last release was 2023-01-11 and the repository has not been updated since 2024-07-10, though it remains unarchived and carries no known vulnerabilities.
License in practice
Apache License 2.0 is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install retry2
from retry2 import retry
@retry(exceptions=ValueError, tries=3, delay=1)
def my_function():
pass
my_function()
Verify before relying
- Whether the package's dormant maintenance status affects its suitability for new projects or production use.
- How well the package's retry semantics integrate with modern async/await patterns.
- Whether the optional decorator dependency is required for your use case or only for signature preservation.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | supports the current Python release (>=2.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — decorator |
| Maintenance | dormant — 1,311 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,237,076/month — #3,195 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: retry2-0.9.5-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
awsretryA decorator that wraps AWS API calls to…
permissive · top 15,000 on PyPI
reretryA decorator and function wrapper for retrying…
permissive · top 15,000 on PyPI
retryProvides a decorator and function wrapper for…
permissive · top 1,000 on PyPI
retry-decoratorProvides a decorator to automatically retry a…
permissive · top 15,000 on PyPI
backoff-utilsProvides functions and decorators to apply…
permissive · top 15,000 on PyPI
aiohttp-retryWraps aiohttp's ClientSession to automatically…
permissive · top 1,000 on PyPI
python-retryProvides a decorator to automatically retry…
permissive · top 15,000 on PyPI
backoffProvides function decorators to automatically…
permissive · top 1,000 on PyPI
python-backoffProvides function decorators for retrying…
permissive · top 5,000 on PyPI
redoRedo provides decorators, functions, and a…
copyleft · top 5,000 on PyPI