Fill up a dictionary in parallel with multiprocessing
Yesterday i asked a question: Reading data in parallel with multiprocess I got very good answers, and i implemented the solution mentioned in the answer i marked as correct. def read_energies(motif): os.chdir("blabla/working_directory") complx_ener = pd.DataFrame() # complex function to fill that dataframe lig_ener = pd.DataFrame() # complex function to fill that dataframe return motif, complx_ener, lig_ener COMPLEX_ENERGIS = {} LIGAND_ENERGIES = {} p = multiprocessing.Pool(processes=CPU) for x in p.imap_unordered(read_energies, peptide_kd.keys()): COMPLEX_ENERGIS[x[0]] = x[1] LIGAND_ENERGIES