def main(): fsm = mortise.StateMachine(initial_state=Ping, final_state=mortise.DefaultStates.End, default_error_state=ErrorState, log_fn=print) # Runs forever fsm.tick()
def loop(msg_queue): # msg_queue should be accessible to another thread which is # handling IPC traffic or otherwise generating events to be # consumed by the state machine fsm = mortise.StateMachine(initial_state=Ping, final_state=mortise.DefaultStates.End, default_error_state=ErrorState, msg_queue=msg_queue, log_fn=print) # Initial kick of the state machine for setup fsm.tick() while True: fsm.tick(msg_queue.get())