Skip to content

Commit

Permalink
feat: retry on JSONDecodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Oct 6, 2022
1 parent 9107497 commit 58baef3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eth_retry/eth_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import logging
import os
from json import JSONDecodeError
from random import randrange
from time import sleep
from typing import Any, Callable
Expand All @@ -28,6 +29,7 @@ def auto_retry(func: Callable[...,Any]) -> Callable[...,Any]:
- HTTPError
- asyncio.exceptions.TimeoutError
- ReadTimeout
- JSONDecodeError
It will also retry on specific ValueError exceptions:
- Max rate limit reached
Expand Down Expand Up @@ -113,6 +115,7 @@ def should_retry(e: Exception, failures: int) -> bool:
HTTPError,
ReadTimeout,
MaxRetryError,
JSONDecodeError,
]
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
Expand Down

0 comments on commit 58baef3

Please sign in to comment.