--- id: retrying version: "1.4.2" license: Apache-2.0 license_treatment: permissive maintenance: active --- # retrying — Retrying License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install retrying uv add retrying poetry add retrying ## Description # Retrying Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything. The simplest use case is retrying a flaky function whenever an Exception occurs until a value is returned. ```python import random from retrying 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()) ``` ## Features - Generic Decorator API - Specify stop condition (i.e. limit by number of attempts) - Specify wait condition (i.e. exponential backoff sleeping between attempts) - Customize retrying on Exceptions - Customize retrying on expected returned result ## Examples As you saw above, the default behavior is to retry forever without waiting. ```python @retry def never_give_up_never_surrender(): print("Retry forever ignoring Exceptions, don't wait between retries") ``` Let's be a little less persistent and set some boundaries, such as the number of attempts before giving up. ```python @retry(stop_max_attempt_number=7) def... ## AI interpretation — verify before relying Retrying is a decorator-based library that adds automatic retry logic to functions, supporting configurable stop conditions (attempt limits, time bounds), wait strategies (fixed delays, exponential backoff, random intervals), and exception/result-based retry decisions. Verdict: Retrying is a lightweight, actively maintained retry utility with zero dependencies, permissive licensing, and broad Python version support. No known vulnerabilities and top-1000 popularity make it a low-risk choice for adding resilience to flaky operations. [View on SkillFed](https://skillfed.io/packages/retrying) · [View on PyPI](https://pypi.org/project/retrying/)