-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to make a new thread #2
Comments
Is HIDAPI even threadsafe like that? I thought the handle initialization had to live on the same thread? |
According to issues/questions in the original signal11 tracker, it is. Specially when C implementation does work (see the linked issue above). How else you would poll for events? |
There's many ways to poll for events without threads. That said, like you mentioned, according to signal11/hidapi#56 hidapi is threadsafe across platforms, so yeah, should probably work in python too. Could be that the cython structure wrapping hidapi isn't threadsafe or something. I currently know very little of cython (I forked because cython-hidapi was missing some functions I needed and the main repo is defunct), but I guess now is as good a time as any to learn. :) |
I think its not caused by cython. I implemented also a C api version with direct calls to hidapi and it behaves same. It seems more like a collision of python and hidapi threading system but I can't imagine how that could happen. |
After a lot of headache I managed to solve it. By a workaround, of course. I replaced hid_read() with hid_read_timeout + added a little sleep in receive_handler(). I still don't understand how this can work in plain C and cannot work in C Api and/or Cython but at least I've got a solution. If you find the real cause, please post it. |
I've started to investigate this issue here: signal11/hidapi#93 -- as it turned out, it was a simple mistake. So definitely, python + hidapi have some trouble together.
I see both 'while 1' and 'while 2' but then the first thread (the main one) is frozen. raw_input() doesn't work anymore. If I put everything in the same thread, it works.
The text was updated successfully, but these errors were encountered: