
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Retry potentially transient HTTP errors in Python.
See documentation.
Several HTTP errors are often transient, and might succeed if retried:
429 Too Many Requests
(rate limited)500 Internal Server Error
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
This project aims to simplify retrying these, by extending tenacity
with custom retry and wait strategies, as well as a custom decorator. Defaults are sensible for most use cases, but are fully customizable.
Supports both requests
and httpx
natively, but could be customized to use with any library that raises exceptions for the conditions listed above.
Install from PyPI:
pip install retryhttp # Supports both HTTPX and requests
You can also install support for only HTTPX or requests, if you would rather not install unnecessary dependencies:
pip install retryhttp[httpx] # Supports only HTTPX
pip install retryhttp[requests] # Supports only requests
Or, install the latest development snapshot from git:
pip install git+https://github.com/austind/retryhttp.git@develop
import httpx
from retryhttp import retry
# Retries safely retryable status codes (429, 500, 502, 503, 504), network errors,
# and timeouts, up to a total of 3 times, with appropriate wait strategies for each
# type of error. All of these behaviors are customizable.
@retry
def example():
response = httpx.get("https://example.com/")
response.raise_for_status()
return response.text
Contributions welcome! Bug fixes and minor tweaks can jump straight to a pull request. For more involved changes, open an issue and let's chat about your idea. Thanks for your contribution!
FAQs
Retry potentially transient HTTP errors in Python.
We found that retryhttp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.