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
Switch from output_async to spawn_async, and buffer output. #6105
Switch from output_async to spawn_async, and buffer output. #6105
Conversation
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.
Looks great, thanks!
@@ -37,6 +38,25 @@ impl CommandRunner { | |||
} | |||
} | |||
|
|||
fn outputs_stream_for_child( | |||
mut child: Child, | |||
) -> Box<Stream<Item = ChildOutput, Error = String> + Send> { |
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.
I know I was the one who said we shouldn't use impl Future
, but I'd be tempted to use impl Stream
here :P My reasoning being:
- This isn't really a thing we do elsewhere, so it probably doesn't add to confusion
- This won't be passed around to other things which may need to ambiguously handle both
But I definitely don't mind either way
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.
Agreed!
.map(move |snapshot| FallibleExecuteProcessResult { | ||
stdout: stdout.freeze(), | ||
stderr: stderr.freeze(), | ||
exit_code: exit_code.unwrap_or(-1), |
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.
I would expect there to always be an exit code, right? Maybe make this an exit_code.ok_or_else(|| "Process had no exit code".to_owned())
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.
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.
Aha, in that case can we do -signal
rather than -1
? :)
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.
Yeeep!
Problem
See #6089.
Solution
Switch to
spawn_async
andfold
over a stream of outputs. To stream/duplicate output elsewhere, we'd add logic in thefold
.Result
Fixes #6089.