When array (data) of more than 10,000, not all processes are finished (see last line print('compete')). When array up to 2,000 elements this code works fine. I think problem with queue, without result_queue.put([i,j]) all processes properly completed. Can anybody help me with this part of code?
def finder(start,end,proc,result_queue,lock):
global data
i=start
while i<=end:
el=data[i]
j=-1
for el1 in data:
j=j+1
s1 = SequenceMatcher(None, el, el1)
s1_val=s1.ratio()
if s1_val>0.9: result_queue.put([i,j])
i=i+1
print('end')
if __name__ == '__main__':
multiprocessing.freeze_support()
result_queue = multiprocessing.Queue()
allProcesses = []
data=r.keys()
print(len(data))
parts=8
part=int(len(data)/parts)
i=0
lock = multiprocessing.Lock()
while i<parts:
p = multiprocessing.Process(target=finder, args=(part*i, part*i+part,i,result_queue,lock ))
print('init',part*i, part*i+part,i)
allProcesses.append(p)
p.daemon = True
p.start()
i=i+1
print('started process',i)
i=0
for p in allProcesses:
p.join()
print('complete')