-
Notifications
You must be signed in to change notification settings - Fork 296
Uinput: Use pipe instead of select() with timeout #1760
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
Conversation
mkrnr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this improvement!
I tested it on Ubuntu and it works well.
GPT-5 flagged some potential lifecycle concerns, but given how this class is used, I don’t see any real issues.
Just a minor note about some unused imports.
Feel free to merge whenever you’re ready.
|
@iansw246 are you allowed to merge on your own? If yes, feel free to do so. If not, let me know when ready and I merge. |
|
I didn't see a merge button after you approved merging (before these new changes), so I assume am not able to merge myself. I think it's ready to merge now. |
mkrnr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a trivial remark regarding a comment. I like the additional error handling!
| log.debug("failed to ungrab device", exc_info=True) | ||
|
|
||
| def start(self): | ||
| # Exception note: cancel() will eventually by called when the machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial: The part "when the machine reconnect machine is pressed" sounds a bit wrong. Maybe remove one "machine"
|
I guess the exception handling counts for defensive programming (a warning message and program carry on is better than Plover hangs/crashes) there's a disadvantage with the extra exception handling though, it makes the code harder to read for developers, and the text says the exact same thing as the code (thus doesn't save the developer any time). I don't know in which case can the exception be thrown at all (if it cannot be thrown the exception handling is obviously redundant), but maybe one case is race condition between the two threads? In that case it may be a better idea to communicate with queues instead, or locks if the above is insufficient. |
Summary of changes
For Linux Uinput, signal the evdev thread to stop using a pipe. Currently, the thread periodically checks a variable to know when to stop.
This eliminates the slight delay between clicking the reconnect button and the reconnection actually happening.
Closes
Pull Request Checklist