Closed Mottl closed 10 months ago
Have you tried setting the preferred behavior using ProgressBar::with_finish()
?
Yes, the same behavior
The ProgressBar
s are going out of scope so MultiProgress
is forgetting about them. You need to clone
them and keep them from getting dropped:
use std::time::Duration;
use indicatif::{MultiProgress, ProgressBar};
fn main() {
eprintln!("Finished progress bars are preserved:");
let multi = MultiProgress::new();
for _ in 0..3 {
let pg = multi.add(ProgressBar::new(5));
for _ in 0..5 {
std::thread::sleep(Duration::from_millis(100));
pg.inc(1);
}
pg.finish();
}
eprintln!("\n\nFinished progress bars are not preserved");
let mut keep = vec![];
let multi = MultiProgress::new();
for _ in 0..3 {
let pg = multi.add(ProgressBar::new(5));
keep.push(pg.clone());
for _ in 0..5 {
std::thread::sleep(Duration::from_millis(100));
pg.inc(1);
multi.println("message").unwrap();
}
pg.finish();
}
}
Related #595
Thanks a lot, Chris 👍️️️️️️ Probably, we could add this to FAQ or in docs.
Thanks a lot, Chris 👍️️️️️️ Probably, we could add this to FAQ or in docs.
You're welcome! And yes absolutely, that's what #595 is about :)
MultiProgress::println
doesn't redraw finished progress bars: