code: def pop(self, n=None):
          
          self.error_buffer.check()
  
          envs = []
  
          if n is None:
              while True:
                  try:
                      envs += self.ready.get(block=False)
                  except queue.Empty:
                      break
          else:
              sync_timeout = 10 * 60
              start = time.time()
  
              wait_time = 1
              while len(envs) < n:
                  try:
                      extra_logger.info('[%s] Waiting for %d envs, currently at %d, sleeping for %d', self.label, n, len(envs), wait_time)
                      envs += self.ready.get(timeout=wait_time)
                  except queue.Empty:
                      self.error_buffer.check()
                  wait_time = min(wait_time * 2, 30)
                  delta = time.time() - start
                  if delta > sync_timeout:
                      raise FatalError("Waited %.0fs to obtain envs, timeout was %.0fs. (Obtained %d/%d envs.)" % (delta, sync_timeout, len(envs), n))
  
          return envs
docs: Call from main thread. Returns the list of newly-available (handle, env) pairs.