Browse Source

We actually need to kill the runner on timeout

master
Julio Biason 1 year ago
parent
commit
f46670400d
  1. 9
      tokiocommandtimeouttest/src/main.rs

9
tokiocommandtimeouttest/src/main.rs

@ -24,17 +24,18 @@ async fn main() {
println!("Run 3 secs"); println!("Run 3 secs");
let mut cmd = Command::new(&sleep).arg("3s").spawn().unwrap(); let mut cmd = Command::new(&sleep).arg("3s").spawn().unwrap();
if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await { if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await {
println!("Got timeout!"); println!("Got timeout!");
cmd.kill().await.unwrap();
} else { } else {
println!("No timeout"); println!("No timeout");
} }
println!("Run 5 secs"); println!("Run 25 secs");
let mut cmd = Command::new(&sleep).arg("5s").spawn().unwrap(); let mut cmd = Command::new(&sleep).arg("25s").spawn().unwrap();
if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await { if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await {
println!("Got timeout") println!("Got timeout");
cmd.kill().await.unwrap();
} else { } else {
println!("No timeout"); println!("No timeout");
} }

Loading…
Cancel
Save