From 028374ede42dba575558ba2b0d7ea2dc3fe33b0f Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 9 Aug 2018 17:08:16 +0900 Subject: [PATCH 1/2] Shield the taking of the lock, otherwise it is lost --- electrumx/server/block_processor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/electrumx/server/block_processor.py b/electrumx/server/block_processor.py index 1645bb7..12edef0 100644 --- a/electrumx/server/block_processor.py +++ b/electrumx/server/block_processor.py @@ -190,8 +190,15 @@ class BlockProcessor(electrumx.server.db.DB): self.state_lock = asyncio.Lock() async def run_in_thread_shielded(self, func, *args): - async with self.state_lock: - return await asyncio.shield(run_in_thread(func, *args)) + # Run in a thread to prevent blocking. Shielded so that + # cancellations from shutdown don't lose work - when the task + # completes the data will be flushed and then we shut down. + # Take the state lock to be certain in-memory state is + # consistent and not being updated elsewhere. + async def run_in_thread_locked(): + async with self.state_lock: + return await run_in_thread(func, *args) + return await asyncio.shield(run_in_thread_locked()) async def check_and_advance_blocks(self, raw_blocks): '''Process the list of raw blocks passed. Detects and handles From 9dff85c027e9e67418a3c9ddca2384f60e45a25d Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 9 Aug 2018 18:13:57 +0900 Subject: [PATCH 2/2] Prepare 1.8.2 --- docs/changelog.rst | 12 ++++++++++-- docs/conf.py | 2 +- electrumx/__init__.py | 2 +- electrumx/server/controller.py | 4 ++-- setup.py | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ddf20b9..b0c850d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,8 +8,15 @@ should not occur with Python 3.7. -Version 1.8.1 (in development) -============================== +Version 1.8.2 (09 Aug 2018) +=========================== + +* require aiorpcX 0.7.1 which along with an ElectrumX change restores clean + shutdown and flush functionality, particularly during initial sync +* fix `#564`_ + +Version 1.8.1 (08 Aug 2018) +=========================== * require aiorpcX 0.7.0 which fixes a bug causing silent shutdown of ElectrumX * fix `#557`_, `#559`_ @@ -206,3 +213,4 @@ bitcoincash:qzxpdlt8ehu9ehftw6rqsy2jgfq4nsltxvhrdmdfpn .. _#538: https://github.com/kyuupichan/electrumx/issues/538 .. _#557: https://github.com/kyuupichan/electrumx/issues/557 .. _#559: https://github.com/kyuupichan/electrumx/issues/559 +.. _#564: https://github.com/kyuupichan/electrumx/issues/564 diff --git a/docs/conf.py b/docs/conf.py index 89e86bd..33afff8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,7 +15,7 @@ import os import sys sys.path.insert(0, os.path.abspath('..')) -VERSION="ElectrumX 1.8.1" +VERSION="ElectrumX 1.8.2" # -- Project information ----------------------------------------------------- diff --git a/electrumx/__init__.py b/electrumx/__init__.py index f3b73de..ceecab7 100644 --- a/electrumx/__init__.py +++ b/electrumx/__init__.py @@ -1,4 +1,4 @@ -version = 'ElectrumX 1.8.1' +version = 'ElectrumX 1.8.2' version_short = version.split()[-1] from electrumx.server.controller import Controller diff --git a/electrumx/server/controller.py b/electrumx/server/controller.py index 6424d0e..2287809 100644 --- a/electrumx/server/controller.py +++ b/electrumx/server/controller.py @@ -80,8 +80,8 @@ class Controller(ServerBase): '''Start the RPC server and wait for the mempool to synchronize. Then start serving external clients. ''' - if not (0, 7) <= aiorpcx_version < (0, 8): - raise RuntimeError('aiorpcX version 0.7.x required') + if not (0, 7, 1) <= aiorpcx_version < (0, 8): + raise RuntimeError('aiorpcX version 0.7.x required with x >= 1') env = self.env min_str, max_str = env.coin.SESSIONCLS.protocol_min_max_strings() diff --git a/setup.py b/setup.py index e48f82f..bc41701 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ import setuptools -version = '1.8.1' +version = '1.8.2' setuptools.setup( name='electrumX', @@ -12,7 +12,7 @@ setuptools.setup( # "blake256" package is required to sync Decred network. # "xevan_hash" package is required to sync Xuez network. # "groestlcoin_hash" package is required to sync Groestlcoin network. - install_requires=['aiorpcX>=0.7,<0.8', 'attrs', + install_requires=['aiorpcX>=0.7.1,<0.8', 'attrs', 'plyvel', 'pylru', 'aiohttp >= 2'], packages=setuptools.find_packages(include=('electrumx*',)), description='ElectrumX Server',