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 logging
import typing
from hub.scribe.daemon import LBCDaemon, DaemonError
if typing.TYPE_CHECKING:
from hub.scribe.network import LBCMainNet
from hub.scribe.daemon import LBCDaemon
def chunks(items, size):
@ -42,8 +42,12 @@ class Prefetcher:
while True:
# Sleep a while if there is nothing to prefetch
await self.refill_event.wait()
try:
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:
if not isinstance(e, asyncio.CancelledError):
self.logger.exception("block fetcher loop crashed")