Friendly state machines for python.

A few questions about automaton.

1.       I would like to know can we addition parameters on on_enter or on_exit 
callbacks. Right now, it  seems it  only allows  state and triggered_event.

a.       I have many FSM running for different objects and it is much easier if 
I can pass on the some sort of ID back to the callbacks.

2.       Can we or how can we store extra attribute like last state change 

3.       Can we store additional identify info for the FSM object? Would like 
to add an UUID



def print_on_enter(new_state, triggered_event):

   print("Entered '%s' due to '%s'" % (new_state, triggered_event))

def print_on_exit(old_state, triggered_event):

   print("Exiting '%s' due to '%s'" % (old_state, triggered_event))

# This will contain all the states and transitions that our machine will

# allow, the format is relatively simple and designed to be easy to use.

state_space = [


        'name': 'stopped',

        'next_states': {

            # On event 'play' transition to the 'playing' state.

            'play': 'playing',

            'open_close': 'opened',

            'stop': 'stopped',


        'on_enter': print_on_enter,

        'on_exit': print_on_exit,

OpenStack Development Mailing List (not for usage questions)

Reply via email to