vbauerster / mpb

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

MPB needs more robust shutdown. #108

Closed joel-rieke closed 2 years ago

joel-rieke commented 2 years ago

Presently we have a long running multi progress bar. Often times several methods associated with different bars fail to complete -- but overall, we don't want to keep going because we know they likely won't ever complete.

At the end, it would be great to have a function that essentially says, I know things haven't gone right, but we're going to shut down anyway and completely clean up the multi progress bar (without exiting the process). We can't let it keep multi progress bar running because several of the bars are still busily waiting.

Calling mpb.Wait() just hangs for us and there doesn't seem to be any way to forcefully shut it down. We tried using a cancellable context, but that does not seem to do the job as I believe one or more WaitGroups in the Wait() method are hanging.

shutdown method is private and I wonder if that were made public if that would be enough to forcefully shut down a multi progress bar?

joel-rieke commented 2 years ago

My bad. I found a way to close everything down.

mathieu-aubin commented 2 years ago

explain? maybe? This will help in the future im certain

joel-rieke commented 2 years ago

Certainment Mathieu.

I had initialize mpb using: ourMpb := mpb.NewWithContext(customContext, mpb.WithWidth(10), mpb.WithWaitGroup(&customWg))

Prior to ourMpb.Wait(), we needed to call customWg.Done(), which we had not done.