30 lines
773 B
Python
30 lines
773 B
Python
|
|
def default_retry_on(exc: Exception) -> bool:
|
||
|
|
import httpx
|
||
|
|
import requests
|
||
|
|
|
||
|
|
if isinstance(exc, ConnectionError):
|
||
|
|
return True
|
||
|
|
if isinstance(exc, httpx.HTTPStatusError):
|
||
|
|
return 500 <= exc.response.status_code < 600
|
||
|
|
if isinstance(exc, requests.HTTPError):
|
||
|
|
return 500 <= exc.response.status_code < 600 if exc.response else True
|
||
|
|
if isinstance(
|
||
|
|
exc,
|
||
|
|
(
|
||
|
|
ValueError,
|
||
|
|
TypeError,
|
||
|
|
ArithmeticError,
|
||
|
|
ImportError,
|
||
|
|
LookupError,
|
||
|
|
NameError,
|
||
|
|
SyntaxError,
|
||
|
|
RuntimeError,
|
||
|
|
ReferenceError,
|
||
|
|
StopIteration,
|
||
|
|
StopAsyncIteration,
|
||
|
|
OSError,
|
||
|
|
),
|
||
|
|
):
|
||
|
|
return False
|
||
|
|
return True
|