def wait_for_unit_state(reactor, docker_client, unit_name, expected_activation_states):
 def is_in_states(units):
  for unit in units:
   if (unit.name == unit_name):
    if (unit.activation_state in expected_activation_states):
     return True
 def check_if_in_states():
  responded = docker_client.list()
  responded.addCallback(is_in_states)
  return responded
 return loop_until(reactor, check_if_in_states)

def wait_for_unit_state ( reactor , docker_client , unit_name , expected_activation_states ) : def is_in_states ( units ) : for unit in units : if ( unit . name == unit_name ) : if ( unit . activation_state in expected_activation_states ) : return True def check_if_in_states ( ) : responded = docker_client . list ( ) responded . addCallback ( is_in_states ) return responded return loop_until ( reactor , check_if_in_states )
wait until a unit is in the requested state .