title: Add Strings to queue recursively using Python
body: <p>I am reading a file with some words using python, adding all items to a queue and then performing operation <code>a</code> using <code>doWork()</code> method. I am trying to figure out, how can I add the results performed in <code>a</code> operations back to the same queue to perform <code>a</code> again on the result itself. The loop needs to stop once the <code>q</code> is empty and it does eventually since the operation <code>a</code> may or may not return the result.</p>
  
  <p>I hope this makes some sense. :P </p>
  
  <pre><code>concurrent = 20
  
  def doWork():
      while True:
          word = q.get()
          lol = getStatus(word)
          q.task_done()
  
  
  def getStatus(word):
      #results another word on which this operation has to be performed.
  
  
  
  q = Queue(concurrent * 2)
  
  for i in range(concurrent):
      t = Thread(target=doWork)
      t.daemon = True
      t.start()
  
  try:
      for words in open('words.txt' ,'r'):
          q.put(words.strip())
      q.join()
  
  except KeyboardInterrupt:
      sys.exit(1)
  </code></pre>