Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiBar only works with threads #59

Open
njaard opened this issue Nov 20, 2017 · 3 comments
Open

MultiBar only works with threads #59

njaard opened this issue Nov 20, 2017 · 3 comments

Comments

@njaard
Copy link

njaard commented Nov 20, 2017

The only way to display multiple progress bars is to use threads, this requirement isn't documented, and when you use single threads, you get silent failures.

@fosskers
Copy link
Contributor

fosskers commented Dec 12, 2020

I'm currently trying to get it working with rayon, we'll see if I'm successful.

@fosskers
Copy link
Contributor

fosskers commented Dec 12, 2020

The following prints nothing, not even the DONE! messages:

pub(crate) fn bar_test() {
    let mb = Arc::new(MultiBar::new());
    std::thread::spawn({
        let mb = Arc::clone(&mb);
        move || {
            mb.listen();
        }
    });

    (0..30).into_par_iter().for_each(|n| {
        let mut bar = mb.create_bar(100);
        bar.message(&format!("{} ", n));

        for _ in 0..100 {
            bar.inc();
            std::thread::sleep(Duration::from_millis(50));
        }

        bar.finish_print("DONE!");
    })
}

The process does complete and exit, which means the loops are occuring, but the bars seem to be lost.

@fosskers
Copy link
Contributor

fosskers commented Dec 12, 2020

If I add a second mb.listen() after the for_each loop, the DONEs all get printed in bulk after the entire thing exits. PR #92 mentions that bars can be created dynamically after the listen has been initiated, but that doesn't seem to work in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants