class DecisionEngineExerciser(object): """ This is a standalone controller which provides a 'mock' environment for running a decision engine. """ def __init__(self, engineclass): self.continue_running = True self.engine = EngineLoader().load(engineclass) self.state = DeeState() self.control = DeeControl(self.state) def run_forever(self): """Initialize the decision engine and call 'decide' until killed.""" conf = {} self.engine.initialize(self.control, self.state, conf) while self.continue_running: time.sleep(self.control.sleep_seconds) self.engine.decide(self.control, self.state) logging.warn("Controller is exiting") def crashing(self): """Experiment with crash scenarios (should the engine API change?)""" self.continue_running = False