Parallel states with Python's transitions package?

Viewed 94
1 Answers

It is possible to implement parallel states with Python's transitions. See the documentation and search for "parallel". You will need to use the HierarchicalMachine as shown

from transitions.extensions import HierarchicalGraphMachine

An example is provided there too:

states = ['A', 'B', {'name': 'C', 
          'parallel': [{'name': '1', 'children': ['a','b','c'], 'initial':'a',
          'transitions': [['go', 'a', 'b']]},
                       {'name': '2', 'children': ['x','y','z'], 'initial':'z'}],
          'transitions': [['go', '2_z', '2_x']]}]

In order to access sub-states, you can refer to them by the {parent_child} name. For instance "C_2" would be state "2" within state "C".

Related