def consume_queue(queue, cascade_stop):
 while True:
  try:
   item = queue.get(timeout=0.1)
  except Empty:
   (yield None)
   continue
  except thread.error:
   raise ShutdownException()
  if item.exc:
   raise item.exc
  if item.is_stop:
   if cascade_stop:
    raise StopIteration
   else:
    continue
  (yield item.item)

def consume_queue ( queue , cascade_stop ) : while True : try : item = queue . get ( timeout = 0.1 ) except Empty : ( yield None ) continue except thread . error : raise ShutdownException ( ) if item . exc : raise item . exc if item . is_stop : if cascade_stop : raise StopIteration else : continue ( yield item . item )
consume the queue by reading lines off of it and yielding them .