-
Notifications
You must be signed in to change notification settings - Fork 111
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
Unblocking read_key()
/ writing to stdin
#188
Comments
I faced the same problem with the same idea of the solution. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been recently writing some async code, and one of the requirements was reading from the consol in raw mode, in a separate thread. Now, this isn't an issue per se:
Using this code snippet, I can put the blocking
read_key()
on it's own thread and be happy. Unfortunately, if I need to cancel this operation I don't have a consistent mechanism to do so. Tokio doesn't really allow me to kill the blocking thread directly, or I don't know of a way. There isn't a pretty way to do async console reading/writing - there are some options on windows, but no idea on unix systems.An alternative would be implementing the functionality to write to stdin. I've made a rough proof-of-conept in a local fork that sends a pre-determined key. A proper system to write to stdin would solve this issue, but does require the implementation of a new feature
Note: my implementation of writing to stdin may not be that stable, but it works for me:
[Source]
The text was updated successfully, but these errors were encountered: