{"id":333,"library":"tenacity","title":"Tenacity","description":"Tenacity is a general-purpose retrying library for Python, designed to simplify adding retry behavior to functions. The current version is 9.1.4, released on February 7, 2026. It follows a regular release cadence, with recent updates addressing Python 3.14 support and improvements to retry annotations. ([pypi.org](https://pypi.org/project/tenacity/?utm_source=openai))","status":"active","version":"9.1.4","language":"python","source_language":"en","source_url":"https://github.com/jd/tenacity","tags":["retry","decorator","Python"],"install":[{"cmd":"pip install tenacity","lang":"bash","label":"Install Tenacity"}],"dependencies":[{"reason":"Tenacity is a fork of the 'retrying' library, offering enhanced functionality and fixes.","package":"retrying"}],"imports":[{"note":"Ensure 'retry' is imported from 'tenacity' to utilize its retrying capabilities.","symbol":"retry","correct":"from tenacity import retry"}],"quickstart":{"code":"import random\nfrom tenacity import retry\n\n@retry\ndef do_something_unreliable():\n    if random.randint(0, 10) > 1:\n        raise IOError('Broken sauce, everything is hosed!!!111one')\n    else:\n        return 'Awesome sauce!'\n\nprint(do_something_unreliable())","lang":"python","description":"A simple example demonstrating the use of Tenacity to retry a function that may raise an IOError."},"warnings":[{"fix":"Update code to use Tenacity's API.","message":"Tenacity is a fork of the 'retrying' library and is not API compatible with it.","severity":"breaking","affected_versions":"All"},{"fix":"Use 'from tenacity import retry' in your imports.","message":"Ensure 'retry' is imported from 'tenacity' to utilize its retrying capabilities.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-05-12T13:07:46.991Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"pip install tenacity","cause":"The 'tenacity' library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'tenacity'"},{"fix":"Add 'from tenacity import retry' at the top of your Python file.","cause":"The 'retry' decorator was used in the code without being imported from the 'tenacity' library.","error":"NameError: name 'retry' is not defined"},{"fix":"Use tenacity helper functions such as 'wait_fixed(N)' or 'stop_after_attempt(N)' for the 'wait' and 'stop' parameters, e.g., '@retry(wait=wait_fixed(2))'.","cause":"The 'wait' or 'stop' parameters of the 'retry' decorator were provided with a non-callable value like an integer, instead of a 'tenacity' helper function.","error":"TypeError: 'int' object is not callable"},{"fix":"Replace 'max_attempts=N' with 'stop=stop_after_attempt(N)' to specify the desired maximum number of attempts.","cause":"The 'retry' decorator does not accept a direct 'max_attempts' argument; the maximum number of attempts is configured using the 'stop' parameter.","error":"TypeError: retry() got an unexpected keyword argument 'max_attempts'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"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":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2.6,"disk_size":"18.0M"},{"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.04,"mem_mb":2.6,"disk_size":"18M"},{"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.12,"mem_mb":3.1,"disk_size":"19.9M"},{"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.09,"mem_mb":3.1,"disk_size":"20M"},{"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.1,"mem_mb":2.9,"disk_size":"11.7M"},{"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.1,"mem_mb":2.9,"disk_size":"12M"},{"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.12,"mem_mb":3.2,"disk_size":"11.4M"},{"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.1,"mem_mb":3,"disk_size":"12M"},{"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.05,"mem_mb":2.4,"disk_size":"17.5M"},{"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.06,"mem_mb":2.4,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}