if __name__ == '__main__':
    m = mp.Manager()
memorizedPaths = m.dict()
filepaths = m.dict()
cutoff = 1
p = mp.Pool(initializer=init_worker, initargs=(memorizedPaths, filepaths,
    cutoff))
degreelist = list(range(100000))
for _ in p.imap_unordered(work, degreelist, chunksize=500):
    pass
p.close()
p.join()
How to utilize all cores with python multiprocessing