Browse Source

use another lock for hid operations

283
ThomasV 9 years ago
parent
commit
49a5994b29
  1. 2
      lib/plugins.py
  2. 1
      plugins/trezor/plugin.py

2
lib/plugins.py

@ -307,6 +307,7 @@ class DeviceMgr(ThreadJob, PrintError):
self.recognised_hardware = set() self.recognised_hardware = set()
# For synchronization # For synchronization
self.lock = threading.RLock() self.lock = threading.RLock()
self.hid_lock = threading.RLock()
self.config = config self.config = config
def thread_jobs(self): def thread_jobs(self):
@ -490,6 +491,7 @@ class DeviceMgr(ThreadJob, PrintError):
# wallet libraries are not affected. # wallet libraries are not affected.
import hid import hid
self.print_error("scanning devices...") self.print_error("scanning devices...")
with self.hid_lock:
hid_list = hid.enumerate(0, 0) hid_list = hid.enumerate(0, 0)
# First see what's connected that we know about # First see what's connected that we know about
devices = [] devices = []

1
plugins/trezor/plugin.py

@ -136,6 +136,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
assert self.main_thread != threading.current_thread() assert self.main_thread != threading.current_thread()
devmgr = self.device_manager() devmgr = self.device_manager()
handler = keystore.handler handler = keystore.handler
with devmgr.hid_lock:
client = devmgr.client_for_keystore(self, handler, keystore, force_pair) client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
# returns the client for a given keystore. can use xpub # returns the client for a given keystore. can use xpub
if client: if client:

Loading…
Cancel
Save