I'm using progressbar 3.6.2, and getting incorrect display output when running multiple progressbars simultaneously. They write "on top" of each other.
Here's a minimum working example:
import multiprocessing as mp
import progressbar
def run_many:
p = mp.Pool(mp.cpu_count(), maxtasksperchild=1)
results = p.map(run_one, args_list)
p.close()
p.join()
def run_one:
with progressbar.Progressbar(max_value=5000) as bar:
for i in range(5000):
do_heavy_lifting(i)
bar.update(i)
I get output that is one line long but oscillates between something that looks like
30% (1500 of 5000) |#######------------| Elapsed Time: 0:00:39 Time: 0:00:39
and
29% (1400 of 5000) |######-------------| Elapsed Time: 0:00:39 Time: 0:00:39
as each thread updates its own progress bar asynchronously. It looks like they're just displaying on top of each other.
Blindly inserting a line-break before going into the loop doesn't work (no surprise); what's a better option?