I am doing some parallel processing, as follows:
with mp.Pool(8) as tmpPool:
results = tmpPool.starmap(my_function, inputs)
where inputs look like: [(1,0.2312),(5,0.52) ...] i.e., tuples of an int and a float.
The code runs nicely, yet I cannot seem to wrap it around a loading bar (tqdm), such as can be done with e.g., imap method as follows:
tqdm.tqdm(mp.imap(some_function,some_inputs))
Can this be done for starmap also?
Thanks!
The temporary solution: rewriting the method to-be-parallelized with imap.
It's not possible with
starmap()
, but it's possible with a patch addingPool.istarmap()
. It's based on the code forimap()
. All you have to do, is create theistarmap.py
-file and import the module to apply the patch before you make your regular multiprocessing-imports.Then in your script: