Skip to content

Commit e3b8ac2

Browse files
committed
v0.1.43 Batch retry middleware now also retries single requests which return an error response.
1 parent 214914f commit e3b8ac2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

IceCreamSwapWeb3/BatchRetryMiddleware.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ def middleware(requests_info) -> list:
2323

2424
if self._w3.rpc_batch_max_size == 0 or len(requests_info) == 1:
2525
# if RPC does not support batch requests or single request in batch, make individual requests
26+
def request_wrapper(method, params):
27+
response = make_batch_request.__self__.make_request(method, params)
28+
if "error" in response and self._w3.should_retry:
29+
raise Exception(response["error"].get("message") or "Unknown RPC Error")
30+
return response
31+
2632
return [
27-
exponential_retry(method)(make_batch_request.__self__.make_request)(
33+
exponential_retry(f"[batch]{method}")(request_wrapper)(
2834
method,
2935
params,
3036
no_retry=not self._w3.should_retry

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
VERSION = '0.1.42'
3+
VERSION = '0.1.43'
44
DESCRIPTION = 'IceCreamSwap Web3.py wrapper'
55
LONG_DESCRIPTION = 'IceCreamSwap Web3.py wrapper with automatic retries, multicall and other advanced functionality'
66

0 commit comments

Comments
 (0)