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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibcpy 3.10–3.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.fixEnsure 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`.fixAlways 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.fixAlways 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.fixVerify 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.