I'm learning multiprocessing in Python 3.6 and here is what I am trying to do. I have two arrays, each of 10 mln records and I have a function:
arrays = []
arr1 = np.random.randint(1,100,10000000)
arr2 = np.random.randint(1,100,10000000)
arrays.append(arr1)
arrays.append(arr2)
#Function
def execFun(arr):
for i in arr:
np.log(i)
I have two cores and knowing that I do the following:
t0 = time.time()
procs = []
for i in range(os.cpu_count()):
proc = multiprocessing.Process(target = execFunc, args = (arrays[i],))
procs.append(proc)
proc.start()
for p in procs:
p.join()
t1 = time.time()
print('time spent: ', t1 - t0)
The above results to BrokenPipeError: [Errno 32] Broken pipe
in here:
58 def dump(obj, file, protocol=None):
59 '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60 ForkingPickler(file, protocol).dump(obj)
Can someone please explain where did I dummy it up?