Use threads to avoid blocking reads/writes in externals. (#1440)

In particular, one thing that we can't (properly) do before this commit
is consuming an infinite input stream. For example:

```
yes | grep y | head -n10
```

will give 10 "y"s in most shells, but blocks indefinitely in nu. This PR
resolves that by doing blocking I/O in threads, and reducing the `await`
calls we currently have in our pipeline code.
This commit is contained in:
Jason Gedge
2020-03-01 12:19:09 -05:00
committed by GitHub
parent ca615d9389
commit 7304d06c0b
10 changed files with 273 additions and 71 deletions

View File

@ -102,7 +102,7 @@ mod it_evaluation {
}
mod stdin_evaluation {
use super::nu_error;
use super::{nu, nu_error};
use nu_test_support::pipeline;
#[test]
@ -117,6 +117,21 @@ mod stdin_evaluation {
assert_eq!(stderr, "");
}
#[test]
fn does_not_block_indefinitely() {
let stdout = nu!(
cwd: ".",
pipeline(r#"
iecho yes
| chop
| chop
| first 1
"#
));
assert_eq!(stdout, "y");
}
}
mod external_words {