def get_all_from_queue(Q):
 try:
  while True:
   (yield Q.get_nowait())
 except Queue.Empty:
  raise StopIteration

def get_all_from_queue ( Q ) : try : while True : ( yield Q . get_nowait ( ) ) except Queue . Empty : raise StopIteration
generator to yield one after the others all items currently in the queue q .