I am writing a python script that will parse through a file quickly by sending lines to different processes to handle. At the end, I want the parent to receive the results f
You can pass values back through an results queue.
In LineConsumer:
def __init__(self, queue, result_queue):
self.result_queue = result_queue
# ...
def terminate(self):
self.results_queue.put(self.lines)
super(LineConsumer, self).terminate()
In Parser:
queue = JoinableQueue(100)
result_queue = Queue()
# ...
lc = LineConsumer(queue, result_queue)
# ...
for p in consumers:
p.terminate()
p.join()
while True:
try:
print results.queue.get(False)
except Queue.Empty: # need to import Queue
break