-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Make subprocess async read non-blocking #76
base: master
Are you sure you want to change the base?
Make subprocess async read non-blocking #76
Conversation
When using option "subprocess_option_enable_async", subprocess was still blocking when calling "subprocess_read_stdout()" and no data were available. Now, subprocess_read_stdout() will return even when no available data, returned value will be equal to 0.
This needs a test case to show why the behaviour was needed before I could land it. |
In my case, this was needed because my main event loop was blocked by this call ( But I'm not sure how to update tests... since they are waiting than read data reach 0 (but this is a blocking event) |
I think if we used one of the process helpers that waits on stdin, we could have a test that launches a process async, reads stdout (asserts that it read nothing), then writes to stdin to unblock the process. I think that'd be enough? I see some other tests fail, most likely because they rely on the async read returning something (even if its returned early). Those tests might have to change to loop until the data is received? |
This is a good idea, I pushed a commit with this behaviour. Is it what you had in mind ? :)
I have fixed those tests by replacing loop condition EDIT: I don't understand, when I run test on local, everything is ok but here on CI pipeline I have error (do you know if CI use particular flags, toolchains ?) |
62fd4b1
to
b65dbc0
Compare
I found this PR while trying to understand what In my code, I use subprocess to spawn an interactive process with a "shell". I can send commands writing to its standard input, terminated by "\n", and then must read the output written to its standard output. I'm currently not using Can anybody clarify to me the intended semantic of |
Hello,
Now, assume our script write to This is when option
Main goal of this PR is because |
When using option "subprocess_option_enable_async", subprocess was still blocking when calling "subprocess_read_stdout()" and no data were available.
Now, subprocess_read_stdout() will return even when no available data, returned value will be equal to 0.
(Note that I only made modification for non-Windows filesystems)