diff --git a/lib/plugins.py b/lib/plugins.py index 0c5db2de..a3679d84 100644 --- 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 index 1f8878af..02823880 100644 --- 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()