Skip to content

Commit

Permalink
Merge pull request #91 from shsmith/master
Browse files Browse the repository at this point in the history
move sleep outside semaphore (issue 88)
  • Loading branch information
Neil authored Dec 26, 2016
2 parents b1e8012 + 62eded5 commit 2d92199
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
version 0.9.19
--------------

- move sleep outside semaphore (issue 88)

version 0.9.18
--------------

Expand Down
9 changes: 5 additions & 4 deletions server/block_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ async def main_loop(self, caught_up_event):
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))
Expand All @@ -113,8 +115,7 @@ async def _prefetch_blocks(self, mempool):
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)
Expand All @@ -140,7 +141,7 @@ async def _prefetch_blocks(self, mempool):
self.fetched_height += count

self.refill_event.clear()

return True

class ChainError(Exception):
'''Raised on error processing blocks.'''
Expand Down
2 changes: 1 addition & 1 deletion server/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "ElectrumX 0.9.18"
VERSION = "ElectrumX 0.9.19"

0 comments on commit 2d92199

Please sign in to comment.