-
Notifications
You must be signed in to change notification settings - Fork 245
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
Spinner not spinning #588
Comments
Can you turn this into a minimal reproduction that doesn't have any dependencies other than indicatif? |
Yeah sure. Here is the code, use indicatif::{ProgressBar, ProgressStyle};
use rayon::prelude::*;
fn waiting(pb: &ProgressBar, n: i32) -> i32 {
std::thread::sleep(std::time::Duration::from_secs(10));
pb.inc(1);
n * n
}
fn main() {
let st = ProgressStyle::with_template("{spinner:.bold} ({pos}/{len}) {msg}").unwrap();
let pb = ProgressBar::new(4 as u64);
pb.set_style(st);
pb.set_message("Syncing buckets from the remote...");
let v = (1..4)
.into_par_iter()
.map(|n| waiting(&pb, n))
.collect::<Vec<_>>();
println!("{v:#?}");
}
[package]
name = "indi"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
indicatif = { version = "0.17.6", features = ["rayon"] }
rayon = "1.7.0" Results: indi.mp4As you can see spinner is stuck and only spins after function returns, whereas it must be spinning all the time unless the spinner finishes (I guess it should be intended). |
I think this behavior is expected? indicatif doesn't spawn a separate thread unless you explicitly enable that (using |
Yes, this is expected behavior. Perhaps we need a documentation change to make it clear that a '{spinner}' doesn't automatically update unless something is driving it. I'd be happy to submit a PR for that. |
@chris-laplante please do! |
I documented this in #593 and then forgot to close this issue. Closing now. |
Hey there, this is my code:
Everything work as expected but the spinner is not spinning as expected it is intended to be spin indefinitely without stopping until all function returns.
not_spinning.mp4
My
Cargo.toml
looks like:The text was updated successfully, but these errors were encountered: