I have a pair of functions defined, where the second is called inside the first, and the second has the associated pipe.recv()
methods for each pipe.send()
method in the first. However the first recv()
method appears to be blocking despite information being in the pipe. Am I calling these in the wrong order? I don't quite understand what the problem is or why the recv()
method would hang in this case. I know it's not a memory issue because the arrays involved are relatively small but I can't think of what the issue could be
def plots():
#build axes and plots
for i in range(num_sections):
temp_arr = pipes_hist[1][0].recv() #the KeyboardInterrupt traceback message points here
arr_section += temp_arr #in my actual code arr_section is predefined with the proper size
#etc etc
def main_function(section_number):
#lots of code goes here
pipes_hist[section_number][1].send(array_section)
pipes_hist[section_number][1].close()
#etc etc
plots()
#build list of pipes for each section
pipes_hist_send = [[] for i in range(num_sections)]
pipes_hist_recv = [[] for i in range(num_sections)]
pipes_hist = list(zip(pipes_hist_recv,pipes_hist_send))
for i in range(num_sections):
pipes_hist[i] = list(pipes_hist[i])
for i in range(num_sections): #these two loops can probably be combined
pipes_hist[i][0],pipes_hist[i][1] = Pipe()
#begin multiprocessing
if __name__ == '__main__':
pool = mp.Pool(num_sections)
args = np.arange(num_sections)
pool.map(main_function, args, chunksize=1)
pool.close()
pool.join()
Edit: The hanging also happens when I change map
to map_async
and call the plots function after the subsequent pool.map_async
instead of inside main_function