Skip to content

Commit

Permalink
Fix: some panics are occuring when creating rayon
Browse files Browse the repository at this point in the history
Wrap and ignore these panics.

I can't reproduce this problem but I'm curious to know if this fixes it
  • Loading branch information
bootandy committed Mar 14, 2023
1 parent e17a1af commit 514bb27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use progress::PIndicator;
use progress::ORDERING;
use std::collections::HashSet;
use std::io::BufRead;
use std::panic;
use std::process;
use sysinfo::{System, SystemExt};

Expand Down Expand Up @@ -190,7 +191,10 @@ fn main() {
progress_data: indicator.data.clone(),
};

let _rayon = init_rayon();
let result = panic::catch_unwind(|| init_rayon);
if result.is_err() {
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
}

let top_level_nodes = walk_it(simplified_dirs, walk_data);

Expand Down Expand Up @@ -248,6 +252,6 @@ fn init_rayon() -> Result<(), ThreadPoolBuildError> {
.stack_size(large_stack)
.build_global()
} else {
Ok(())
rayon::ThreadPoolBuilder::new().build_global()
}
}

0 comments on commit 514bb27

Please sign in to comment.