You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have had issues in the past of threads not closing
properly. When you set up a raw data handler, pywinusb
creates two threads:
InputReportProcessing
InputReportReader
and in theory, if you script everything correctly, and all your functions
get returned, and you do the proper cleanup, that these threads will (should)
close on their own.
However, i have had instances where this did not take place. I have seen
on stackoverflow there are many people who try to terminate/abort threads,
and because of the locks, it just doesn't seem to be effective.
threading._after_fork()
I discovered this function, that... doesn't seem to be documented, but... the nearest
i can tell, it calls an additional function that is designed to "reset all locks" for python.
This function seems to work wonderfully, and is a good way of freeing up our threads.
I'm not sure if it is something that could be incorporated into the project, because...
you would hate to close all threads or locks that should be in place.... but, maybe it
could still be incorporated... or at very least documented as a last resort option.
Here is code also, to list the threads (for troubleshooting).
for t in threading.enumerate():
print(t.getName())
The text was updated successfully, but these errors were encountered:
Thanks @warrenarea, do you have more details of what version of os, python and pyWinUsb you had when hitting the threading issues?
@c1728p9 invested a lot of time tuning the threading, specially on scenarios involving removing devices. So any hints about reproducing the failures would be appreciated.
I wouldn't discard using a known workaround for sure, can you point us to such discussion threads?
I have had issues in the past of threads not closing
properly. When you set up a raw data handler, pywinusb
creates two threads:
and in theory, if you script everything correctly, and all your functions
get returned, and you do the proper cleanup, that these threads will (should)
close on their own.
However, i have had instances where this did not take place. I have seen
on stackoverflow there are many people who try to terminate/abort threads,
and because of the locks, it just doesn't seem to be effective.
threading._after_fork()
I discovered this function, that... doesn't seem to be documented, but... the nearest
i can tell, it calls an additional function that is designed to "reset all locks" for python.
This function seems to work wonderfully, and is a good way of freeing up our threads.
I'm not sure if it is something that could be incorporated into the project, because...
you would hate to close all threads or locks that should be in place.... but, maybe it
could still be incorporated... or at very least documented as a last resort option.
Here is code also, to list the threads (for troubleshooting).
The text was updated successfully, but these errors were encountered: