move sleep outside semaphore (issue 88)

This commit is contained in:
shsmith 2016-12-26 09:15:22 -08:00
parent b1e8012b56
commit 62eded55bb
3 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,8 @@
version 0.9.19
--------------
- move sleep outside semaphore (issue 88)
version 0.9.18 version 0.9.18
-------------- --------------

View File

@ -89,7 +89,9 @@ class Prefetcher(LoggedClass):
while True: while True:
try: try:
with await self.semaphore: 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() await self.refill_event.wait()
except DaemonError as e: except DaemonError as e:
self.logger.info('ignoring daemon error: {}'.format(e)) self.logger.info('ignoring daemon error: {}'.format(e))
@ -113,8 +115,7 @@ class Prefetcher(LoggedClass):
if not count: if not count:
self.cache.put_nowait(([], 0)) self.cache.put_nowait(([], 0))
self.caught_up = True self.caught_up = True
await asyncio.sleep(5) return False
return
first = self.fetched_height + 1 first = self.fetched_height + 1
hex_hashes = await self.daemon.block_hex_hashes(first, count) hex_hashes = await self.daemon.block_hex_hashes(first, count)
@ -140,7 +141,7 @@ class Prefetcher(LoggedClass):
self.fetched_height += count self.fetched_height += count
self.refill_event.clear() self.refill_event.clear()
return True
class ChainError(Exception): class ChainError(Exception):
'''Raised on error processing blocks.''' '''Raised on error processing blocks.'''

View File

@ -1 +1 @@
VERSION = "ElectrumX 0.9.18" VERSION = "ElectrumX 0.9.19"