code: def _clear_queue(to_clear):
      
  
      while not to_clear.empty():
          try:
              to_clear.get(False)
              to_clear.task_done()
          except queue.Empty:
              continue
docs: Clear all items from a queue safely.