pytransitions / transitions

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

model.trigger() only supports first machine associated with the model #480

Closed jsatt closed 3 years ago

jsatt commented 3 years ago

When setting up multiple machines on a model, the trigger method that is patched onto the model only supports the first machine and ignores all others. It appears that there was at least some attempt to support multiple machines from trigger until the machine arg of machine._get_trigger was removed in 160035154.

aleneum commented 3 years ago

Hello @jsatt,

did you see "Transitions does not add convencience methods to my model" in the FAQs? Is OverrideMachine or CallingMachine helpful for your use case?

jsatt commented 3 years ago

I did not see that. This just seemed like a potential bug or unintended change since the commit which caused the change stated it was to make "all tests pass" and the docstring still includes the details of the old signature. This should probably be updated if the change was intentional.

I will and see if the FAQ example helps, but I was also able to use lower level functionality to solve my particular issue. Thanks for the feedback.

aleneum commented 3 years ago

You are right, _get_trigger was initially a function in the core module and was moved into Machine later on. In this procedure, machine as an argument was removed (replaced with self). I will remove this parameter from the docstring. The method is still there though but instead of _get_trigger(model, machine, 'func') it is now executed with machine._get_trigger(model, 'func'). Behaviour-wise it should still be the same.

aleneum commented 3 years ago

Closing this due to inactivity. If you there is more to add, feel free to comment anyway. I will reopen the issue when necessary.