Skip to content

Commit

Permalink
Avoiding ctrl-c handling in parallel --progress
Browse files Browse the repository at this point in the history
Related to #328
  • Loading branch information
Yomguithereal committed Oct 29, 2024
1 parent 6a93b35 commit b1a2d44
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/cmd/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ impl Bars {
self.abandon();
}

fn interrupt(&self) {
for (path, bar) in self.bars.lock().unwrap().iter() {
bar.set_style(get_spinner_style(path.yellow()));
bar.tick();
bar.abandon();
}

self.set_color("yellow");
self.main.abandon();
}
// fn interrupt(&self) {
// for (path, bar) in self.bars.lock().unwrap().iter() {
// bar.set_style(get_spinner_style(path.yellow()));
// bar.tick();
// bar.abandon();
// }

// self.set_color("yellow");
// self.main.abandon();
// }
}

struct ParallelProgressBar {
bars: Option<Arc<Bars>>,
bars: Option<Bars>,
}

impl ParallelProgressBar {
Expand All @@ -120,17 +120,9 @@ impl ParallelProgressBar {
}

fn new(total: usize) -> Self {
let bars = Arc::new(Bars::new(total));

let handle = bars.clone();

ctrlc::set_handler(move || {
handle.interrupt();
std::process::exit(1);
})
.expect("Could not setup ctrl+c handler!");

Self { bars: Some(bars) }
Self {
bars: Some(Bars::new(total)),
}
}

fn start(&self, path: &str) -> Option<ProgressBar> {
Expand Down

0 comments on commit b1a2d44

Please sign in to comment.