I'm executing a paralelized function using Pool.starmap function. The execution of the function it self only takes 6.5 minutes according to tqdm library but the program stays in execution for 20 min more until it finishes. The function is processing and applying filters to some strings in some colums of a pandas dataframe. A different paralelized function could perform better? There is something wrong with starmap function?
Functon to be executed:
def get_best_string_filters(hst, apolnmar, apolnmod, apolnsub, apolnterm, amodnanu, ps, cc, cilindros, combustible, gearbox, year, search_model, search_version, search_container):
select = table_ecode[(table_ecode.HST == hst)]
year = int(year[-4:])
select = initial_selection(select, ps, cc, cilindros, combustible, gearbox, year)
temp = get_starting_selection(select.copy(), search_model, "HTB")
if temp.empty:
search_model, search_version, search_container = find_best_combination(select, search_model, search_version, search_container)
else:
select = temp.copy()
_, search_version, search_container = find_best_combination(select, "", search_version, search_container)
#print(search_model, search_version, search_container)
return [apolnmar, apolnmod, apolnsub, apolnterm, amodnanu, search_model, search_version, search_container]
starmap call:
if not exists("dict_search_ammo_make_version_fixed.npy"):
params = [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) for a, b, c, d, e, f, g, h, i, j, k, l, m, n, o in values_to_change.values]
with Pool(mp.cpu_count()) as ex:
array_split_ammo_make_version = ex.starmap(get_best_string_filters, tqdm(params, total=len(params)))
dict_split_ammo_make_version = array_to_dict(array_split_ammo_make_version)
# save the dict to disk for faster future executions
np.save("dict_search_ammo_make_version_fixed.npy", dict_split_ammo_make_version)
else:
dict_split_ammo_make_version = np.load('dict_search_ammo_make_version_fixed.npy',allow_pickle='TRUE').item()
tqdm outputs 6.5 minutes and a completed status but the script continues to run for 20 long minutes: