This commit is contained in:
parent
f7eca425eb
commit
59043a9add
1 changed files with 7 additions and 3 deletions
|
@ -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()
|
||||||
|
try:
|
||||||
if not await self._prefetch_blocks():
|
if not await self._prefetch_blocks():
|
||||||
await asyncio.sleep(self.polling_delay)
|
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")
|
||||||
|
|
Loading…
Reference in a new issue