Skip to content

Commit 1399846

Browse files
fix(criterion_compat): properly wait for python benchmark process
1 parent a1f5dd2 commit 1399846

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/criterion_compat/benches/criterion_integration/external_process.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ fn python_fibonacci(c: &mut Criterion) {
2323
.is_ok();
2424

2525
if has_python3 {
26-
let process = create_command()
26+
let mut process = create_command()
2727
.stdin(Stdio::piped())
2828
.stdout(Stdio::piped())
2929
.spawn()
3030
.expect("Unable to start python process");
3131

3232
let mut stdin = process
3333
.stdin
34+
.take()
3435
.expect("Unable to get stdin for child process");
3536
let stdout = process
3637
.stdout
38+
.take()
3739
.expect("Unable to get stdout for child process");
3840
let mut stdout = BufReader::new(stdout);
3941
c.bench_function("fibonacci-python", |b| {
@@ -51,6 +53,9 @@ fn python_fibonacci(c: &mut Criterion) {
5153
});
5254

5355
// Ensure that your child process terminates itself gracefully!
56+
process
57+
.wait()
58+
.expect("Child process did not terminate gracefully");
5459
}
5560
}
5661

0 commit comments

Comments
 (0)