console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.43k stars 243 forks source link

MultiProgress should support tokio (async) #125

Closed manuels closed 3 years ago

manuels commented 5 years ago

While ProgressBar works fine with tokio, MultiProgress does not, because there is only a blocking join() function. It would be great if indicatif's MultiProgress would support tokio!

softprops commented 5 years ago

I think I just hit this problem as well. I can't see MultiProgress bars rendered at all until after the tokio future was complete.

mitsuhiko commented 5 years ago

I would accept patches for this. I'm not sure how to best approach this.

DmitrySoshnikov commented 4 years ago

Yeah, would be great to proceed on this issue. For now as a workaround I found spawning a thread of a sync function, which delegates to the generic async implementation with task::block_on.

Stargateur commented 4 years ago

Given mp a MultiProgress with tokio you should do let mp = tokio::task::spawn_blocking(move || mp.join().unwrap()); await it with mp.await in your main task if you want.