Skip to content

Commit 2823133

Browse files
committed
Use async command spawning so that timeouts can happen mid-compilation
1 parent be2e7dd commit 2823133

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collector/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ semver = "1.0"
2121
reqwest = { version = "0.11", features = ["json"] }
2222
xz2 = "0.1.3"
2323
tar = "0.4"
24-
tokio = { version = "1.6", features = ["rt"] }
24+
tokio = { version = "1.6", features = ["rt", "process"] }
2525
database = { path = "../database" }
2626
intern = { path = "../intern" }
2727
futures = "0.3.5"

collector/src/compile/execute/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::compile::benchmark::profile::Profile;
55
use crate::compile::benchmark::scenario::Scenario;
66
use crate::compile::benchmark::BenchmarkName;
77
use crate::toolchain::Toolchain;
8-
use crate::{command_output, utils};
8+
use crate::{async_command_output, command_output, utils};
99
use anyhow::Context;
1010
use bencher::Bencher;
1111
use database::QueryLabel;
@@ -309,7 +309,8 @@ impl<'a> CargoProcess<'a> {
309309

310310
log::debug!("{:?}", cmd);
311311

312-
let output = command_output(&mut cmd)?;
312+
let cmd = tokio::process::Command::from(cmd);
313+
let output = async_command_output(cmd).await?;
313314
if let Some((ref mut processor, scenario, scenario_str, patch)) = self.processor_etc {
314315
let data = ProcessOutputData {
315316
name: self.processor_name.clone(),

collector/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,30 @@ pub fn command_output(cmd: &mut Command) -> anyhow::Result<process::Output> {
221221
Ok(output)
222222
}
223223

224+
pub async fn async_command_output(
225+
mut cmd: tokio::process::Command,
226+
) -> anyhow::Result<process::Output> {
227+
use anyhow::Context;
228+
229+
let child = cmd
230+
.stdout(Stdio::piped())
231+
.stderr(Stdio::piped())
232+
.spawn()
233+
.with_context(|| format!("failed to spawn process for cmd: {:?}", cmd))?;
234+
let output = child.wait_with_output().await?;
235+
236+
if !output.status.success() {
237+
return Err(anyhow::anyhow!(
238+
"expected success, got {}\n\nstderr={}\n\n stdout={}\n",
239+
output.status,
240+
String::from_utf8_lossy(&output.stderr),
241+
String::from_utf8_lossy(&output.stdout)
242+
));
243+
}
244+
245+
Ok(output)
246+
}
247+
224248
#[derive(Debug, Clone, Deserialize)]
225249
pub struct MasterCommit {
226250
pub sha: String,

0 commit comments

Comments
 (0)