pywinusb icon indicating copy to clipboard operation
pywinusb copied to clipboard

InputReportProcessingThread is never closed

Open adriencarbonaro opened this issue 3 years ago • 0 comments

I've noticed that when I count the number of active threads, the InputReportProcessingThread is always active, even when device is disconnected.

The following line abort the InputReportReaderThread when device is disconnected but not the InputReportProcessingThread one. https://github.com/rene-aguirre/pywinusb/blob/bbf8c54c78c38740d4878e0d4802b6d997918610/pywinusb/hid/core.py#L730

Step to reproduce :

  • Connect the HID device to the PC (Windows 10)
  • Count number of active threads using threading.active_count().
    • There should be 1 if no other threads have been launched.
    • I added a name parameter to the InputReportReaderThread and InputReportProcessingThread constructors so I can print active threads names :
    for t in threading.enumerate():
        print(t.name)
    
  • Use the API to find a device.
  • Before the device is opened, I see 1 active MainThread.
  • After the device is opened, I see 3 active threads (MainThread, tRead, tProc).
  • When I disconnect the device (unplug), and re check number and names of threads, I see 2 threads (MainThread, tProc).

adriencarbonaro avatar Nov 25 '20 15:11 adriencarbonaro