mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 11:54:02 +01:00
Merge pull request #1108 from thegedge/faster-pipelines
Wait for process instead of polling its status.
This commit is contained in:
commit
1fe85cb91e
@ -170,29 +170,17 @@ pub(crate) async fn run_external_command(
|
||||
|
||||
let name_tag = command.name_tag.clone();
|
||||
if let Ok(mut popen) = popen {
|
||||
popen.detach();
|
||||
match stream_next {
|
||||
StreamNext::Last => {
|
||||
popen.detach();
|
||||
loop {
|
||||
match popen.poll() {
|
||||
None => {
|
||||
std::thread::sleep(std::time::Duration::new(0, 100_000_000));
|
||||
}
|
||||
_ => {
|
||||
let _ = popen.terminate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = popen.wait();
|
||||
Ok(ClassifiedInputStream::new())
|
||||
}
|
||||
StreamNext::External => {
|
||||
popen.detach();
|
||||
let stdout = popen.stdout.take().unwrap();
|
||||
Ok(ClassifiedInputStream::from_stdout(stdout))
|
||||
}
|
||||
StreamNext::Internal => {
|
||||
popen.detach();
|
||||
let stdout = popen.stdout.take().unwrap();
|
||||
let file = futures::io::AllowStdIo::new(stdout);
|
||||
let stream = Framed::new(file, LinesCodec {});
|
||||
|
Loading…
Reference in New Issue
Block a user