Skip to content

Commit

Permalink
fix: handle exceptions in jsonrpc batching (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Sep 1, 2022
1 parent e9433cd commit 9624aa6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dank_mids/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ async def process_batch_multicall(self, batches: List[List[BatchedCall]], jid: O
try:
async with aiohttp.ClientSession(timeout=AIOHTTP_TIMEOUT) as session:
responses = await session.post(self.controller.w3.provider.endpoint_uri, json=jsonrpc_batch)
responses = [response['result'] for response in await responses.json()]
await gather([self.process_multicall_response(batch, to_bytes(response)) for batch, response in zip(batches, responses)])
responses = await responses.json()

# A successful response will be a list
if isinstance(responses, dict) and 'result' in responses and isinstance(responses['result'], dict) and 'message' in responses['result']:
raise ValueError(responses['result']['message'])

await gather([self.process_multicall_response(batch, to_bytes(response)) for batch, response in zip(batches, [response['result'] for response in responses])])
demo_logger.info(f'request {rid} for jsonrpc batch {jid} complete')
except Exception as e:
if "out of gas" in str(e):
Expand Down

0 comments on commit 9624aa6

Please sign in to comment.