vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.31k stars 123 forks source link

Bar not removed after context canceled in interactive shell #77

Closed Prnyself closed 4 years ago

Prnyself commented 4 years ago

I try to use progress bar in go-prompt,it works well when task completed itself. But, if I interrupted the task by Ctrl + C and canceled the context (used to create the progress by NewWithContext), the progress bar still keeps rendering in my shell, even if I can input new cmd and run it.

Prnyself commented 4 years ago

And it is possible in some condition that after task done, the bar is still rendering just like canceled mentioned above.

Prnyself commented 4 years ago

Whoops, I've found what I missed. I didn't call Wait() when context canceled. So the progress did not shutdown. By the way, maybe consider to make shutdown() a public method cuz 'shutdown' is quite not familiar with 'wait'?

vbauerster commented 4 years ago

Glad you solved it.

By the way, maybe consider to make shutdown() a public method cuz 'shutdown' is quite not familiar with 'wait'?

Wait method doesn't shutdown the progress pool, it just waits until underlying bars are completed and completion could be triggered either by normal current == total or by cancel context.

Wait method waits for opportunity to safely shutdown the progress pool, that's why shutdown method it calls is not a public.