I'm trying to increase the execution time of my python program by using some multiprocessing. Suppose I have this sample code:
def foo(q,x,y):
....
q.put(result)
def parallel_funtion(x):
q1 = Queue(); q2 = Queue()
p1 = Process(target=foo,
args=[q1,x,0])
p2 = Process(target=foo,
args=[q2,x,1])
p1.start(); p2.start()
p1.join(); p2.join()
z = max(q1.get(), q2.get())
return z
def function(list)
.....
for i in list:
parallel_function(i)
main():
function(aList)
After the first iteration in the cycle in "function" the program freezes specifically in this row:
z = max(q1.get(), q2.get())
Why?
The question is short on specifics, but this works for me... I modified your use of
list
, since that appears to destroy python'slist
method (although as you say, the code still executes):Output: