Registry / testing / retry-decorator

retry-decorator

JSON →
library1.1.1pypypi✓ verified 85d ago

The `retry-decorator` library provides a simple yet powerful decorator for retrying function calls upon specified exceptions. It supports features like setting maximum retries, exponential backoff, and logging failed attempts. Version 1.1.1 is the latest release, with future versions planned to drop Python 2 support. The project appears to be actively maintained, though releases are infrequent.

pip install retry-decorator
INSTALL
IMPORT
SIG · RETRY-DECORATOR
R
retry-decorator
testingpythonv1.1.1
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.1 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

retry
from retry_decorator import retry
from python_retry import retry

This example demonstrates how to use the `@retry` decorator with explicit exception handling, a maximum number of retries, and a basic backoff factor. It also configures a logger to show retry attempts.

import logging from python_retry import retry LOGGER = logging.getLogger(__name__) @retry(max_retries=3, backoff_factor=1, retry_on=(ValueError,), retry_logger=LOGGER) def flaky_function(): print("Attempting flaky operation...") if hasattr(flaky_function, 'calls'): flaky_function.calls += 1 else: flaky_function.calls = 1 if flaky_function.calls < 3: raise ValueError("Simulated transient error") print("Operation successful!") return "Success Data" if __name__ == "__main__": try: result = flaky_function() print(f"Final result: {result}") except ValueError as e: print(f"Operation failed after multiple retries: {e}")
Debug
Known issues
breakingVersion 1.1.1 is the last to officially support Python 2. While minor backports might be considered for Python 2.7, future major versions will likely be Python 3 only, potentially breaking compatibility for older environments.
fix
Ensure your project runs on Python 3 for future compatibility or pin your dependency to `retry-decorator<2.0` if Python 2 support is critical.
affects: 1.1.1 and earlier
gotchaThe PyPI package name is `retry-decorator`, but the correct Python import statement is `from python_retry import retry`. Using `from retry_decorator import ...` will result in an `ImportError`.
fix
Always use `from python_retry import retry` to import the decorator.
affects: All versions
gotchaBy default, the `@retry()` decorator catches `Exception` (i.e., all exceptions) if the `retry_on` parameter is not explicitly specified. This broad catching can mask unexpected errors in your application logic that should not trigger a retry.
fix
Always explicitly list the exceptions you intend to retry using the `retry_on` parameter (e.g., `retry_on=(ConnectionError, TimeoutError)`). This makes your retry logic more robust and prevents unintended behavior.
affects: All versions
gotchaThere are several Python libraries with similar names and functionality (e.g., `retry`, `retrying`, `retry-reloaded`). Users might accidentally install or import the wrong library, leading to different APIs and unexpected behavior.
fix
Verify that `pip install retry-decorator` was used and that `from python_retry import retry` is the correct import for this specific library. Cross-reference the documentation if you encounter API discrepancies.
affects: All versions
Upgrade
Version history
1.1.1latest on PyPI · released Mar 10, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
2
Amazon
1
Resources
retry-decorator — pip install retry-decorator · libregistry