I want to populate a 2D-numpy array in a for loop and consolidate the calculation using multiprocessing.
import numpy from multiprocessing import Pool array_2D = numpy.zeros((20,10)) pool = Pool(processes = 4) def fill_array(start_val): return range(start_val,start_val+10) list_start_vals = range(40,60) for line in xrange(20): array_2D[line,:] = pool.map(fill_array,list_start_vals) pool.close() print array_2D
The effect of its execution is that Python starts 4 subprocesses and takes 4 processor cores, but the execution does not end and the array is not printed. If I try to write an array to disk, nothing will happen.
Can someone tell me why?
python arrays numpy multiprocessing pool
MoTSCHIGGE
source share