I've recently discovered that the apply_async
method in multiprocessing.Pool
has a limit on the size of the arguments passed in args=()
. Is that really the case or am I doing something wrong?
I've attached an example code where I simply print the shape of the matrix in the called functions. As you can see, at size 21000
the function is no longer being called (and no exception or warning are being raised :\ )
import numpy as np
from multiprocessing import Pool
def _mp_print_size(mat):
try:
print 'Mat size [%d %d]' % (mat.shape[0], mat.shape[1])
except Warning as w:
print w
except Exception as e:
print e
def diff_sizes(size):
print 'Running with size ', size
mat = np.ones([size, size])
pool = Pool(2)
for i in range(2):
pool.apply_async(func=_mp_print_size, args=(mat, ))
pool.close()
pool.join()
if __name__ == '__main__':
sizes = np.arange(1000, 1000000, 10000)
for s in sizes:
diff_sizes(s)
And the print out of this is:
Running with size 1000
Mat size [1000 1000]
Mat size [1000 1000]
Running with size 11000
Mat size [11000 11000]
Mat size [11000 11000]
Running with size 21000
Running with size 31000
Running with size 41000
Running with size 51000
Running with size 61000
I'm sorry if this questions was asked - linked to previous instances of it will be much appreciated as I could not find it myself.