Eric-Canas / USBMonitor

USBMonitor is an easy-to-use cross-platform library for USB device monitoring that simplifies tracking of connections, disconnections, and examination of connected device attributes on both Windows and Linux, freeing the user from platform-specific details or incompatibilities.
MIT License
33 stars 7 forks source link

Error when USB-HUB remove #2

Closed zhuyu4839 closed 8 months ago

zhuyu4839 commented 12 months ago

Error when USB-HUB remove:

usbmonitor/__platform_specific_detectors/_linux_usb_detector.py", line 76, in __handle_device_event device_info = self.last_check_devices[device_id].copy()


KeyError: '/dev/bus/usb/001/026'

platform: Manjaro Linux distribute
python version: 3.11.5
francisjeanneau commented 8 months ago

Can confirm that this occurs not only with hubs, but with USB devices too.

 Exception in thread Thread-2:
 Traceback (most recent call last):
   File "~/.environment/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
     self.run()
   File "~/.environment/lib/python3.11/site-packages/pyudev/monitor.py", line 544, in run
     self._callback(device)
   File "~/.environment/lib/python3.11/site-packages/usbmonitor/__platform_specific_detectors/_linux_usb_detector.py", line 76, in __handle_device_event
     device_info = self.last_check_devices[device_id].copy()
                   ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
 KeyError: '/dev/bus/usb/001/109'

This error breaks the monitoring deamon. No further connect or disconnect is detected past this point.

Eric-Canas commented 8 months ago

Thanks to @francisjeanneau for finding and solving the issue!