You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure this was solved, if I create multiple instances of a state machine -- the newest statemachines class variables will serve as the single point of truth for all state machines.
fromstatemachineimportStatefromstatemachineimportStateMachineclassTestStateMachine(StateMachine):
# Statesst_1=State("One", initial=True)
st_2=State("Two")
st_3=State("Three")
# Transitionstr_change= (
st_1.to(st_2, cond="two")
|st_2.to(st_3, cond="three")
|st_3.to(st_1, cond="one")
)
def__init__(self, name="unnamed"):
# variablesself.sm_name=nameself.one=Falseself.two=Trueself.three=Falsesuper().__init__()
s1=TestStateMachine()
s2=TestStateMachine()
s1.current_stateState('One', id='st_1', value='st_1', initial=True, final=False)
s2.current_stateState('One', id='st_1', value='st_1', initial=True, final=False)
s1.tr_change()
s1.current_stateState('Two', id='st_2', value='st_2', initial=False, final=False)
s2.current_stateState('One', id='st_1', value='st_1', initial=True, final=False)
s2.two=Falses2TestStateMachine(model=Model(state=st_1), state_field='state', current_state='st_1')
s2.tr_change()
statemachine.exceptions.TransitionNotAllowed: Can'ttr_changewheninOne.
s1.three=Trues1.threeTrues2.threeFalses1.tr_change() # this shouldn't throw an error because s1.three is now truestatemachine.exceptions.TransitionNotAllowed: Can'ttr_changewheninTwo.
s2.three=True# When I change the variable on s2, it then allows me to transition the state of s1s1.tr_change()
s1.current_stateState('Two', id='st_2', value='st_2', initial=False, final=False)
I am not sure this was solved, if I create multiple instances of a state machine -- the newest statemachines class variables will serve as the single point of truth for all state machines.
Originally posted by @KellyP5 in #330 (comment)
The text was updated successfully, but these errors were encountered: