is_retryable_http_exception

Documentation for eth_defi.middleware.is_retryable_http_exception function.

is_retryable_http_exception(exc, retryable_exceptions=(<class 'requests.exceptions.ConnectionError'>, <class 'requests.exceptions.HTTPError'>, <class 'requests.exceptions.Timeout'>, <class 'requests.exceptions.TooManyRedirects'>), retryable_status_codes=(429, 500, 502, 503, 504), retryable_rpc_error_codes=(-32603, ))[source]

Helper to check retryable errors from JSON-RPC calls.

Retryable reasons are connection timeouts, API throttling and such.

We support various kind of exceptions and HTTP status codes we know we can try.

Parameters
  • exc (Exception) – Exception raised by requests or Web3 machinery.

  • retryable_exceptions (Tuple[BaseException]) – Exception raised by requests or Web3 machinery.

  • retryable_status_codes (Collection[int]) – HTTP status codes we can retry. E.g. 429 Too Many requests.

  • retryable_rpc_error_codes (Collection[int]) –