def wait_for_status_change(self, parameters, conn, state_requested, 
    max_wait_time=60, poll_interval=10):
    time_start = time.time()
    instance_ids = parameters[self.PARAM_INSTANCE_IDS]
    instances_in_state = {}
    while True:
      time.sleep(poll_interval)
      reservations = conn.get_all_instances(instance_ids)
      instances = [i for r in reservations for i in r.instances]
      for i in instances:
        if i.state == state_requested and \
         i.key_name.startswith(parameters[self.PARAM_KEYNAME]):
          if i.id not in instances_in_state.keys():
            instances_in_state[i.id] = 1 # mark instance done
    if len(instances_in_state.keys()) >= len(instance_ids):
      return True
    if time.time() - time_start > max_wait_time:
      return False
.. todo::
dataset/ETHPy150Open AppScale/appscale-tools/lib/agents/openstack_agent.py/OpenStackAgent.wait_for_status_change--crossover with--dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/cuda_convnet/probabilistic_max_pooling.py/ProbMaxPoolGrad.c_code