Please Review this basic example
def queue_add():
#this will exit when all lines from the
#file are added in the Queue
with open('get_from.txt') as f:
for line in f:
q.add(line.strip())
def queue_save():
#when to trigger save_to.close()?!?!
save_to = open('save_to.txt')
while True:
data = q.get() #this functions blocks if `q` is empty, so how to know
#when to close the file handler `save_to`??
save_to.write(data)
def worker():
#this is daemon process
while True:
#work with file from
get = q.get()
#work with data
q_done.put('processed data')
q.task_done()
q = Queue()
q_done = Queue()
#starts the processes here..
So my question is how to know queue_save()
has processed and saved all the data from the done_q and close it's file_handler?