skillfed

retry2

Easy to use retry decorator.

retry2 v0.9.5 2.2M downloads/30d#3,195 on PyPI30
Permissive license Apache License 2.0 DORMANT released

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 retry2

uv

uv add retry2

poetry

poetry add retry2

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development

Tags

retry decoratorautomatic retry logicexponential backoffexception retry handlerfunction retry wrapperretry with delayresilience decorator
resiliencedecoratorbackoff

More Software Development packages