I have a program using python multiprocessing. I find that all the process created in the main programs can be finished but the main programs is always waiting for the return values and can not stop. Can anybody give me some suggestions on how to solve this problem?
The code snippets is as follows:
main program:
workers = multiprocessing.Pool(4)
args = [arg1, arg2, arg3, arg4]
results = workers.map(subfunc, args)
print "we are in main functions "
subfunc(*arg)
# doing some other jobs
result = {.....} # a large dictionary
print 'done with sub functions'
return result # if I change it to "return 1", it can finish successfully
I can see the output "done with sub functions" for all the processes created in main, but no outputs "we are in main functions". Can anybody help me figure out the problem?