pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.52k stars 525 forks source link

Improve isolation in HSM (for reuse and export) #362

Closed aleneum closed 4 years ago

aleneum commented 4 years ago

Currently, it can be tough to reuse modules if the content and state names are not known (see #332).

Current Issues

Required (currently available) features

New Features

NestedState:
    name: 'StateName'
    states: []  # list of NestedState
    models: []  # list of local models  
aleneum commented 4 years ago

I opted for (shared) nested states and events and used context managers to readjust the current scope of a Machine. This leads to recursive code and frequent tree searches. "Deep-first" vs "Breadth-first" strategies had to be applied to get the callback execution order (hopefully) right.