tuse another lock for hid operations - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 49a5994b291293b1bda9f891a8b4c6ca886e3560 DIR parent 82a33bf89e782d93b0ba5bbffefb85a52db8e7b3 HTML Author: ThomasV <thomasv@electrum.org> Date: Sat, 27 Aug 2016 15:46:01 +0200 use another lock for hid operations Diffstat: M lib/plugins.py | 4 +++- M plugins/trezor/plugin.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) --- DIR diff --git a/lib/plugins.py b/lib/plugins.py t@@ -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): t@@ -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: DIR diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py t@@ -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()