def _adjust_instances(self):
    now = time.time()
    with self._condition:
      _, not_required_instances = self._split_instances()

    if len(not_required_instances) < self._min_idle_instances:
      self._add_instance(permit_warmup=True)
    elif (len(not_required_instances) > self._max_idle_instances and
          now >
          (self._last_instance_quit_time + self._MIN_SECONDS_BETWEEN_QUITS)):
      for inst in not_required_instances:
        if not inst.num_outstanding_requests:
          try:
            inst.quit()
          except instance.CannotQuitServingInstance:
            pass
          else:
            self._last_instance_quit_time = now
            logging.debug('Quit instance: %s', inst)
            with self._condition:
              self._instances.discard(inst)
              break
API wrapper documentation
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/server.py/AutoScalingServer._adjust_instances--crossover with--dataset/ETHPy150Open pingali/dgit/dgitcore/api.py/api_call_action