Skip to content

Commit

Permalink
Use Rayon's panic_fuse to not spawn more threads on panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Dec 6, 2023
1 parent 594056b commit fb73560
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crates/solidity/testing/sanctuary/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
mod datasets;
mod reporting;

use std::{
collections::BTreeSet, ops::ControlFlow, panic::catch_unwind, path::Path, process::ExitCode,
};
use std::{collections::BTreeSet, ops::ControlFlow, path::Path, process::ExitCode};

use anyhow::Result;
use infra_utils::paths::PathExtensions;
Expand All @@ -22,11 +20,9 @@ fn main() -> Result<ExitCode> {
let versions = SolidityDefinition::create().collect_breaking_versions();

for dataset in get_all_datasets()? {
let res = catch_unwind(|| process_dataset(&dataset, &versions)).expect("A child panicked.");

match res? {
ControlFlow::Break(exit_code) => return Ok(exit_code),
match process_dataset(&dataset, &versions)? {
ControlFlow::Continue(..) => {}
ControlFlow::Break(exit_code) => return Ok(exit_code),
}
}

Expand Down Expand Up @@ -56,6 +52,8 @@ fn process_dataset(

source_files
.par_iter()
// Halt as soon as possible if a child panics.
.panic_fuse()
.map(|file_path| {
process_source_file(file_path, versions, &reporter)?;
reporter.report_file_completed();
Expand Down

0 comments on commit fb73560

Please sign in to comment.