You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Several HTTP errors are often transient, and might succeed if retried:
19
19
20
20
This project aims to simplify retrying these, by extending [`tenacity`](https://tenacity.readthedocs.io/) with custom retry and wait strategies, as well as a custom decorator. Defaults are sensible for most use cases, but are fully customizable.
21
21
22
-
Supports both [`requests`](https://docs.python-requests.org/en/latest/index.html), [`httpx`](https://python-httpx.org/) and [`aiohttp`](https://docs.aiohttp.org/) natively, but could be customized to use with any library that raises exceptions for the conditions listed above.
22
+
Supports [`requests`](https://docs.python-requests.org/en/latest/index.html), [`httpx`](https://python-httpx.org/), [`httpx2`](https://httpx2.pydantic.dev/) and [`aiohttp`](https://docs.aiohttp.org/) natively, but could be customized to use with any library that raises exceptions for the conditions listed above.
23
23
24
24
## Install
25
25
@@ -33,6 +33,7 @@ You can also install support for only HTTPX or requests, if you would rather not
33
33
34
34
```sh
35
35
pip install retryhttp[httpx] # Supports only HTTPX
36
+
pip install retryhttp[httpx2] # Supports only HTTPX2
36
37
pip install retryhttp[requests] # Supports only requests
37
38
pip install retryhttp[aiohttp] # Supports only aiohttp
# and timeouts, up to a total of 3 times, with appropriate wait strategies for each
64
+
# type of error.
65
+
@retry
66
+
defget_example():
67
+
response = httpx2.get("https://example.com/")
68
+
response.raise_for_status()
69
+
return response.text
70
+
```
71
+
56
72
!!! note
57
73
`retryhttp` works by catching exceptions, so your code must raise those exceptions. Most of the time, all you need is to call `response.raise_for_status()`. Be sure not to catch those exceptions in your own `try..except` block.
0 commit comments