progress bar starmap_async multiprocessing python

Viewed 143

I have build a multiprocessor to speed up the processes (300.000 params), however it would be nice if it shows a progress bar of something like that so I can keep track of the progress. I searched on the stackoverflow for a proper solution however cannot find similar questions. Is it possible to use a progress method on starmap_async? if not, what could be a good alternative?

import multiprocessing as mp

def origins(G, x, y):
  return ox.get_nearest_node(G, (y, x))

x = [buildings.geometry[i].centroid.y for i in list(range(len(buildings)))]
y = [buildings.geometry[i].centroid.y for i in list(range(len(buildings)))]
params = ((G, orig, dest) for orig, dest in zip(y, x))

# create a pool of worker processes
pool = mp.Pool(4)

# map the function/parameters to the worker processes
sma = pool.starmap_async(origins, params)

# get the results, close the pool, wait for worker processes to all exit
routes = sma.get()
pool.close()
pool.join()

Can someone help me out?

0 Answers
Related