Python - Progress bar for every Process

Viewed 122

I'm running same operations with different data/different models as separate processes, and I want to see a progress bar for every process. They each take different time to complete. My imports:

from multiprocessing import Process
import tqdm

I'm running processes like this:

t1 = Process(target=func, args=(x.copy(), y.copy(), table_ax, 0.001, 1, 1))
t2 = Process(target=func, args=(x.copy(), y.copy(), table_ax_b, 0.001, 1, 2))
t3 = Process(target=func, args=(x.copy(), y.copy(), table_axx_bsinx_c, 0.001, 1, 3))

t1.start()
t2.start()
t3.start()

t1.join()
t2.join()
t3.join()

And I tried to display progress bars with tqdm by doing this(inside func):

for i in tqdm.trange(100000):
    # some operations

Problem is, those bars overlap in the same line in terminal until one of them finishes(which leaves 100% bar and problem continues in new line), and at the end of every process results are printed to console, which messes formatting even more. I can forgo printing results if there's no practical way to do it, but I need bars to be in separate lines. Is there a solution to this?

0 Answers
Related