From 62eded55bb701e31cbe62f6d51667dab4662fbe8 Mon Sep 17 00:00:00 2001 From: shsmith Date: Mon, 26 Dec 2016 09:15:22 -0800 Subject: [PATCH] move sleep outside semaphore (issue 88) --- RELEASE-NOTES | 5 +++++ server/block_processor.py | 9 +++++---- server/version.py | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7c83946..37f3eb6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,8 @@ +version 0.9.19 +-------------- + +- move sleep outside semaphore (issue 88) + version 0.9.18 -------------- diff --git a/server/block_processor.py b/server/block_processor.py index a62badc..9227a96 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -89,7 +89,9 @@ class Prefetcher(LoggedClass): while True: try: with await self.semaphore: - await self._prefetch_blocks(caught_up_event.is_set()) + fetched = await self._prefetch_blocks(caught_up_event.is_set()) + if not fetched: + await asyncio.sleep(5) await self.refill_event.wait() except DaemonError as e: self.logger.info('ignoring daemon error: {}'.format(e)) @@ -113,8 +115,7 @@ class Prefetcher(LoggedClass): if not count: self.cache.put_nowait(([], 0)) self.caught_up = True - await asyncio.sleep(5) - return + return False first = self.fetched_height + 1 hex_hashes = await self.daemon.block_hex_hashes(first, count) @@ -140,7 +141,7 @@ class Prefetcher(LoggedClass): self.fetched_height += count self.refill_event.clear() - + return True class ChainError(Exception): '''Raised on error processing blocks.''' diff --git a/server/version.py b/server/version.py index a0336c0..be314a9 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.9.18" +VERSION = "ElectrumX 0.9.19"