{"id":696,"library":"retrying","title":"Python Retrying Library","description":"Retrying is an Apache 2.0 licensed general-purpose Python library designed to simplify the task of adding retry behavior to functions. It allows developers to configure retry logic for transient failures, specifying stop conditions, wait strategies (like exponential backoff), and conditions for retrying based on exceptions or return values. The current version is 1.4.2.","status":"maintenance","version":"1.4.2","language":"python","source_language":"en","source_url":"https://github.com/groodt/retrying","tags":["retries","retry","backoff","error handling","resilience"],"install":[{"cmd":"pip install retrying","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Compatibility layer for Python 2 and 3, required by the library.","package":"six","optional":false}],"imports":[{"symbol":"retry","correct":"from retrying import retry"},{"symbol":"stop_after_attempt","correct":"from retrying import stop_after_attempt"},{"symbol":"wait_fixed","correct":"from retrying import wait_fixed"},{"symbol":"wait_exponential","correct":"from retrying import wait_exponential"}],"quickstart":{"code":"import random\nimport os\nfrom retrying import retry, stop_after_attempt, wait_fixed\n\n@retry(stop_max_attempt_number=5, wait_fixed=1000) # Retry up to 5 times, waiting 1 second between attempts\ndef do_something_unreliable():\n    if random.randint(0, 10) > 2: # Simulate a failure 70% of the time\n        print(\"Operation failed, retrying...\")\n        raise IOError(\"Simulated transient error\")\n    else:\n        print(\"Operation successful!\")\n        return \"Awesome sauce!\"\n\ntry:\n    result = do_something_unreliable()\n    print(f\"Final result: {result}\")\nexcept IOError as e:\n    print(f\"Operation failed after multiple retries: {e}\")\n","lang":"python","description":"Demonstrates how to use the `@retry` decorator with `stop_max_attempt_number` and `wait_fixed` to retry a function that might fail intermittently. By default, `@retry` retries on any exception indefinitely and without delay, so it's crucial to configure stop and wait conditions."},"warnings":[{"fix":"Consider migrating to `tenacity` (`pip install tenacity`). Be aware that `tenacity` is not API-compatible with `retrying`, requiring code changes. Refer to `tenacity`'s documentation for migration guidance.","message":"The `retrying` library is generally considered unmaintained. Its active development ceased some time ago, and `tenacity` is an actively developed fork that addresses shortcomings and adds new features. Users are strongly encouraged to migrate to `tenacity` for ongoing support, bug fixes, and new capabilities.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always configure `stop_max_attempt_number`, `stop_max_delay`, `wait_fixed`, `wait_exponential`, or similar parameters to define clear termination conditions and appropriate delays. For example: `@retry(stop_max_attempt_number=7, wait_fixed=2000)`.","message":"The default behavior of the `@retry` decorator is to retry *forever* on any exception, with *no delay* between attempts. This can lead to infinite loops, high CPU usage, and rapid resource exhaustion in production systems if not explicitly configured with stop and wait strategies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update any `print` statements in your code or copied examples from `print \"hello\"` to `print(\"hello\")` to be compatible with Python 3.","message":"Older examples or documentation for `retrying` (especially from its earlier development stages) might use Python 2 `print` syntax (e.g., `print \"message\"`). Since the library now requires Python 3.6+, ensure all `print` statements use the function syntax (`print(\"message\")`).","severity":"gotcha","affected_versions":"<=1.3.3 (examples), all versions (user code)"},{"fix":"Verify the installed version of `retrying` and ensure it is compatible with your code and Python version. A more robust solution is to migrate to the actively maintained `tenacity` library, where stop and wait conditions are structured as `from tenacity import retry, stop_after_attempt, wait_fixed` (and usage patterns might differ). Refer to `tenacity` documentation for correct usage.","message":"The `ImportError: cannot import name 'stop_after_attempt' from 'retrying'` indicates that the `stop_after_attempt` function (and potentially other helper functions like `wait_fixed`) is not directly available for import from the top-level `retrying` module in the installed version. This commonly occurs due to an outdated or incompatible version of the `retrying` library being installed, or potential conflicts with newer Python environments (like Python 3.13) which the unmaintained `retrying` library may not fully support.","severity":"breaking","affected_versions":"All versions (due to potential version mismatch or Python compatibility issues with unmaintained `retrying` library)"}],"env_vars":null,"last_verified":"2026-05-12T17:55:14.785Z","next_check":"2026-06-26T00:00:00.000Z","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"1.4.2","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"17.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"17.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.01,"mem_mb":1,"disk_size":"18M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":1,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.2,"disk_size":"19.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.2,"disk_size":"19.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.03,"mem_mb":1.2,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.2,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1,"disk_size":"11.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0.03,"mem_mb":1,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.3,"disk_size":"11.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.3,"disk_size":"11.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.03,"mem_mb":1.1,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.1,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"17.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.7,"disk_size":"17.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0.01,"mem_mb":0.9,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.9,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}