I am struggling with getting tqdm's progress bar to stay and update as opposed to write to a new line. Note: I am using multiprocessing to parallelize my code, and tqdm is inside the function I am parallelizing.
I added a print statement so the files will all appear in my terminal when running the program. Reproducible example below:
import multiprocessing
import time
from tqdm import tqdm
from joblib import Parallel, delayed
def run_file_analysis(text):
cool = []
for i in tqdm(range(0, 10), position = 0, leave = True, desc = f'Text : {text}'):
print('')
cool.append(i)
time.sleep(1)
num_cores = multiprocessing.cpu_count()
ls = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
if __name__ == "__main__":
processed_list = Parallel(n_jobs=num_cores)(delayed(run_file_analysis)(i) for i in ls)
The desired output would be the ten text objects - 1, 2, 3, ... , 10 and a corresponding updating progress bar for each. Not 100 different ones. I have tried following many stackoverflow questions relating to the topic of tqdm and multiprocessing integration, but none of them are as straightforward as I would like them to be. Any help would be appreciated.
