code: def _drain(queue_to_drain, sentinel=None):
      
      queue_to_drain.put(sentinel)
      queued_items = [i for i in iter(queue_to_drain.get, None)]
      return queued_items
docs: Remove all values from queue_to_drain and return as list.
  
      This uses the trick from
      http://stackoverflow.com/questions/
      1540822/dumping-a-multiprocessing-queue-into-a-list in order to ensure that
      the queue is fully drained.