Registry / http-networking / retry
library0.9.2pypypi✓ verified 27d ago

The `retry` library (version 0.9.2) provides a simple decorator for adding retry logic to Python functions. It allows configuration of exceptions to catch, number of attempts, delay between retries, backoff strategy, and optional jitter. This library is largely unmaintained, with its last release in 2016, and is superseded by more actively developed alternatives like `tenacity`.

pip install retry
INSTALL
IMPORT
SIG · RETRY
R
retry
http-networkingpythonv0.9.2
Install
1.7s avg
Import
53ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.054s · 18.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.052s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

retry
from retry import retry
from retrying import retry
The 'retrying' library is a different, also unmaintained, project that `tenacity` forked from. This `retry` library has a distinct import path.

This quickstart demonstrates how to apply the `@retry` decorator to a function, configuring it to retry on specific exceptions, with a maximum number of attempts, an initial delay, exponential backoff, and a maximum delay between retries. It will print logging messages for each retry attempt.

import random from retry import retry import logging logging.basicConfig(level=logging.INFO) @retry(exceptions=(IOError, ValueError), tries=3, delay=2, backoff=2, max_delay=10) def unreliable_function(): if random.randint(0, 5) > 2: raise IOError("Simulated network error") elif random.randint(0, 5) < 1: raise ValueError("Simulated data error") else: print("Function succeeded!") return "Success" try: result = unreliable_function() print(f"Final result: {result}") except (IOError, ValueError) as e: print(f"Function failed after all retries: {e}")
Debug
Known issues
breakingThis 'retry' library (invl/retry) is largely unmaintained, with its last release in 2016. Its API is not compatible with 'tenacity', which is the actively maintained successor to the 'retrying' library (another distinct, unmaintained project).
fix
Consider migrating to `tenacity` (pip install tenacity) for active development, better features, and bug fixes. Tenacity offers a more robust and flexible API for retry strategies.
affects: <=0.9.2
gotchaBy default, the `@retry` decorator will retry indefinitely if the `tries` parameter is not explicitly set or set to -1.
fix
Always set a finite `tries` value (e.g., `tries=5`) or a `max_delay` to prevent infinite loops in production environments.
affects: <=0.9.2
gotchaThe `retry` decorator does not inherently support asynchronous functions (async/await syntax).
fix
For asynchronous code, you will need to use a different retry library that explicitly supports `async/await`, such as `tenacity` with `AsyncRetrying` or `stamina`.
affects: <=0.9.2
gotchaWhen using `jitter`, if a tuple `(min, max)` is provided, the extra delay is chosen randomly. If a single number is provided, the jitter is fixed.
fix
Be aware of the type of `jitter` parameter passed. For true random jitter to prevent 'thundering herd' problems, provide a tuple (e.g., `jitter=(0, 1)`).
affects: <=0.9.2
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'retry'
The 'retry' library has not been installed in your Python environment.
fix
Run 'pip install retry' in your terminal.
TypeError: retry() missing 1 required positional argument: 'f'
The `@retry` decorator was called with arguments but without the necessary parentheses for the decorator factory, causing it to be interpreted as if it's decorating a function directly.
fix
Always use parentheses when providing arguments to the decorator, even if empty: `@retry(tries=3)` instead of `@retry(tries=3)`.
AttributeError: module 'retry' has no attribute 'retry'
After `import retry`, the user attempted to access `retry.retry`. The `retry` module itself is the decorator function, so you should use `retry` directly.
fix
If you `import retry`, use `@retry(...)` or `retry(func, ...)`. If you `from retry import retry`, then use `@retry(...)` or `retry(func, ...)`.
TypeError: retry() got an unexpected keyword argument 'wait'
The 'retry' library does not recognize the keyword argument 'wait' (commonly used in other retry libraries like 'tenacity'). It expects 'delay' for the wait time.
fix
Replace unsupported arguments like 'wait' with the correct argument 'delay' (e.g., `@retry(delay=2)` instead of `@retry(wait=2)`).
Upgrade
Version history
0.9.2latest on PyPI · released May 11, 2016
Audit
Dependencies
decoratoroptionalUsed to optionally preserve function signatures when decorating, not strictly required for core functionality.
Agent activity
16 hits · last 30 days
node
14
Resources
retry — pip install retry · libregistry