code: def wait_for_idle(self):
          
  
          # Be mindful that this is being executed in a different greenlet than the work_* methods.
  
          while True:
  
              time.sleep(0.01)
  
              with self.work_lock:
  
                  if self.status != "wait":
                      continue
  
                  if len(self.gevent_pool) > 0:
                      continue
  
                  # Force a refresh of the current subqueues, one might just have been created.
                  self.refresh_queues()
  
                  # We might be dequeueing a new subqueue. Double check that we don't have anything more to do
                  outcome, dequeue_jobs = self.work_once(free_pool_slots=1, max_jobs=None)
  
                  if outcome is "wait" and dequeue_jobs == 0:
                      break
docs: Waits until the worker has nothing more to do. Very useful in tests