This commit is contained in:
Jack Robison 2022-08-30 11:30:18 -04:00
parent f7eca425eb
commit 59043a9add
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -1,9 +1,9 @@
import asyncio import asyncio
import logging import logging
import typing import typing
from hub.scribe.daemon import LBCDaemon, DaemonError
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from hub.scribe.network import LBCMainNet from hub.scribe.network import LBCMainNet
from hub.scribe.daemon import LBCDaemon
def chunks(items, size): def chunks(items, size):
@ -42,8 +42,12 @@ class Prefetcher:
while True: while True:
# Sleep a while if there is nothing to prefetch # Sleep a while if there is nothing to prefetch
await self.refill_event.wait() await self.refill_event.wait()
if not await self._prefetch_blocks(): try:
await asyncio.sleep(self.polling_delay) if not await self._prefetch_blocks():
await asyncio.sleep(self.polling_delay)
except DaemonError as err:
self.logger.warning("block prefetcher failed: '%s', retrying in 5 seconds", err)
await asyncio.sleep(5)
except Exception as e: except Exception as e:
if not isinstance(e, asyncio.CancelledError): if not isinstance(e, asyncio.CancelledError):
self.logger.exception("block fetcher loop crashed") self.logger.exception("block fetcher loop crashed")