runner worker error reports

This commit is contained in:
Tim Olson
2023-12-28 21:40:52 -04:00
parent 8a9813baed
commit 52cb2f8ad0

View File

@@ -174,30 +174,35 @@ class BlockStateRunner:
async def worker(self):
log.debug(f'runner worker started')
w3 = current_w3.get()
chain = current_chain.get()
assert chain.chain_id == await w3.eth.chain_id
current_clock.set(BlockClock())
prev_head = None
while self.running:
try:
async with asyncio.timeout(1): # check running flag every second
head = await self.queue.get()
except TimeoutError:
log.debug('timeout in runner')
# 1 second has passed without a new head. Run the postprocess callbacks to check for activated time-based triggers
if prev_head is not None:
await self.handle_time_tick(head)
else:
try:
log.debug(f'runner worker started')
w3 = current_w3.get()
chain = current_chain.get()
assert chain.chain_id == await w3.eth.chain_id
current_clock.set(BlockClock())
prev_head = None
while self.running:
try:
log.debug('handle head...')
await self.handle_head(chain, head, w3)
log.debug('handled')
prev_head = head
except Exception as x:
log.exception(x)
log.debug('runner worker exiting')
async with asyncio.timeout(1): # check running flag every second
head = await self.queue.get()
except TimeoutError:
log.debug('timeout in runner')
# 1 second has passed without a new head. Run the postprocess callbacks to check for activated time-based triggers
if prev_head is not None:
await self.handle_time_tick(head)
else:
try:
log.debug('handle head...')
await self.handle_head(chain, head, w3)
log.debug('handled')
prev_head = head
except Exception as x:
log.exception(x)
except:
log.exception('exception in runner worker')
raise
finally:
log.debug('runner worker exiting')
async def handle_head(self, chain, blockhash, w3):