I am using multiprocessing in Python 3.7 to kickoff several long running operations. Each individual process takes a couple minutes to complete. I want a progress bar for each individual process that is running displayed simultaneously. I've been having trouble getting this to work as the progress bars are constantly jumping around and replacing each other in my current futile attempt.
I create my processes like this:
with Pool(processes=cpu_count()) as pool:
return pool.starmap(_execute_long_running_process, items)
Inside my _execute_long_running_process
function is a for
loop that I want the progress bar to track.
for i in tqdm(list_of_things_to_process, leave=False):
# do a thing
I believe my issue arises from each tqdm
progress bar existing in its own process separate from the main process. I'm not sure what the workaround would be to make them behave as I expect where I have several progress bars each being updated.