Skip to content

Commit 247cb16

Browse files
committed
Upgrade to tokio 1.0
1 parent 7a4ef73 commit 247cb16

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ http = "0.2"
2222
failure = "0.1.3"
2323
futures-util = "0.3.5"
2424
log = "0.4.6"
25-
tokio = { version = "0.2.21", features = ["process", "time", "io-util", "stream", "rt-core", "rt-threaded"] }
25+
tokio = { version = "1.0", features = ["process", "time", "io-util", "rt", "rt-multi-thread"] }
26+
tokio-stream = { version = "0.1", features = ["io-util"] }
2627
serde = { version = "1.0", features = ["derive"] }
2728
serde_json = "1.0"
2829
scopeguard = "1.0.0"

src/cmd/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use tokio::{
2424
io::{AsyncBufReadExt, BufReader},
2525
process::Command as AsyncCommand,
2626
runtime::Runtime,
27-
stream::StreamExt,
2827
time,
2928
};
29+
use tokio_stream::{wrappers::LinesStream, StreamExt};
3030

3131
lazy_static::lazy_static! {
3232
// TODO: Migrate to asynchronous code and remove runtime
@@ -480,7 +480,6 @@ impl<'w, 'pl> Command<'w, 'pl> {
480480
}
481481

482482
let out = RUNTIME
483-
.handle()
484483
.block_on(log_command(
485484
cmd,
486485
self.process_lines,
@@ -574,13 +573,11 @@ async fn log_command(
574573
};
575574

576575
let mut child = cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
577-
let child_id = child.id();
576+
let child_id = child.id().unwrap();
578577

579-
let stdout = BufReader::new(child.stdout.take().unwrap())
580-
.lines()
578+
let stdout = LinesStream::new(BufReader::new(child.stdout.take().unwrap()).lines())
581579
.map(|line| (OutputKind::Stdout, line));
582-
let stderr = BufReader::new(child.stderr.take().unwrap())
583-
.lines()
580+
let stderr = LinesStream::new(BufReader::new(child.stderr.take().unwrap()).lines())
584581
.map(|line| (OutputKind::Stderr, line));
585582

586583
let start = Instant::now();
@@ -642,7 +639,7 @@ async fn log_command(
642639
},
643640
);
644641

645-
let child = time::timeout(timeout, child).map(move |result| {
642+
let child = time::timeout(timeout, child.wait()).map(move |result| {
646643
match result {
647644
// If the timeout elapses, kill the process
648645
Err(_timeout) => Err(match native::kill_process(child_id) {

0 commit comments

Comments
 (0)