Skip to content

Commit

Permalink
feat: retry on asyncio.exceptions.TimeoutError (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Jun 6, 2022
1 parent f669718 commit 0672512
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion eth_retry/eth_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def auto_retry(func: Callable[...,Any]) -> Callable[...,Any]:
- requests.exceptions.ConnectionError
- HTTPError
- TimeoutError
- asyncio.exceptions.TimeoutError
- ReadTimeout
It will also retry on specific ValueError exceptions:
Expand Down Expand Up @@ -95,7 +96,14 @@ def should_retry(e: Exception, failures: int) -> bool:
if any(err in str(e).lower() for err in retry_on_errs):
return True

general_exceptions = [ConnectionError, requests.exceptions.ConnectionError, HTTPError, TimeoutError, ReadTimeout]
general_exceptions = [
ConnectionError,
requests.exceptions.ConnectionError,
HTTPError,
TimeoutError,
asyncio.exceptions.TimeoutError,
ReadTimeout
]
if any(isinstance(e, E) for E in general_exceptions) and 'Too Large' not in str(e) and '404' not in str(e):
return True
# This happens when brownie's deployments.db gets locked. Just retry.
Expand Down

0 comments on commit 0672512

Please sign in to comment.