finaldata parallelization

This commit is contained in:
tim
2024-08-13 22:41:22 -04:00
parent d9bc031f72
commit 5c89c69299
2 changed files with 4 additions and 3 deletions

View File

@@ -26,9 +26,8 @@ ohlcs: FinalOHLCRepository
async def handle_backfill_uniswap_swaps(swaps: list[EventData]):
# asynchronously prefetch the block timestamps we'll need
block_ids = set(swap['blockHash'] for swap in swaps)
for batch in itertools.batched(block_ids, 4):
await asyncio.gather(*[get_block_timestamp(h) for h in batch])
block_hashes = set(swap['blockHash'] for swap in swaps)
await asyncio.gather(*[get_block_timestamp(h) for h in block_hashes])
# now execute the swaps synchronously
for swap in swaps:

View File

@@ -150,3 +150,5 @@ class RetryHTTPProvider (AsyncHTTPProvider):
await asyncio.sleep(wait)
finally:
self.rate_allowed.set()
# finally:
# log.debug(f'Ended request of RPC call {method}')