electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 49a5994b291293b1bda9f891a8b4c6ca886e3560
parent 82a33bf89e782d93b0ba5bbffefb85a52db8e7b3
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 27 Aug 2016 15:46:01 +0200

use another lock for hid operations

Diffstat:
Mlib/plugins.py | 4+++-
Mplugins/trezor/plugin.py | 3++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/plugins.py b/lib/plugins.py @@ -307,6 +307,7 @@ class DeviceMgr(ThreadJob, PrintError): self.recognised_hardware = set() # For synchronization self.lock = threading.RLock() + self.hid_lock = threading.RLock() self.config = config def thread_jobs(self): @@ -490,7 +491,8 @@ class DeviceMgr(ThreadJob, PrintError): # wallet libraries are not affected. import hid self.print_error("scanning devices...") - hid_list = hid.enumerate(0, 0) + with self.hid_lock: + hid_list = hid.enumerate(0, 0) # First see what's connected that we know about devices = [] for d in hid_list: diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py @@ -136,7 +136,8 @@ class TrezorCompatiblePlugin(HW_PluginBase): assert self.main_thread != threading.current_thread() devmgr = self.device_manager() handler = keystore.handler - client = devmgr.client_for_keystore(self, handler, keystore, force_pair) + with devmgr.hid_lock: + client = devmgr.client_for_keystore(self, handler, keystore, force_pair) # returns the client for a given keystore. can use xpub if client: client.used()