if __name__ == '__main__':
    p = Pool(5)
result = np.zeros((4, 4))

def adder(value):
    global result
result += value
for i in range(30):
    p.apply_async(f, args=(i,), callback=adder)
p.close()
p.join()
print(result)
Python multiprocessing for parallel processes