1
0

hww hidapi usage: try to mitigate some thread-safety issues

related: #6097
This commit is contained in:
SomberNight
2020-04-17 19:05:56 +02:00
parent 98d2ab5bd6
commit 2cfa3bd6c8
6 changed files with 66 additions and 25 deletions

View File

@@ -72,9 +72,9 @@ class CKCCClient(HardwareClientBase):
self.dev = ElectrumColdcardDevice(dev_path, encrypt=True)
else:
# open the real HID device
import hid
hd = hid.device(path=dev_path)
hd.open_path(dev_path)
with self.device_manager().hid_lock:
hd = hid.device(path=dev_path)
hd.open_path(dev_path)
self.dev = ElectrumColdcardDevice(dev=hd, encrypt=True)
@@ -127,7 +127,8 @@ class CKCCClient(HardwareClientBase):
def close(self):
# close the HID device (so can be reused)
self.dev.close()
with self.device_manager().hid_lock:
self.dev.close()
self.dev = None
def is_initialized(self):