-
-
Couldn't load subscription status.
- Fork 101
Description
From https://python-statemachine.readthedocs.io/en/latest/guards.html#conditions:
This feature allows for multiple transitions on the same Event, with each Transition checked in the order they are declared.
I was actually about to file a bug report, but rereading this passage made me try something unintuitive that appears to have answered my question. Basically, it seems a bit confusing (and worth documenting more specifically) that what matters for a particular Event is the order in which the various transitions are defined elsewhere, rather than their order in the Event's TransitionList. For example:
last_thing_to_check = s.FOO.to(s.QUX)
second_thing_to_check = s.FOO.to(s.BAZ)
@second_thing_to_check.cond
def second_thing_to_check_cond(self):
# ...
first_thing_to_check = s.FOO.to(s.BAR)
@first_thing_to_check.cond
def first_thing_to_check_cond(self):
# ...
go_somewhere = first_thing_to_check | second_thing_to_check | last_thing_to_checkI was struggling to figure out why go_somewhere was just doing last_thing_to_check without testing any of the conditional transitions. I'm not sure whether this is a bug, but I found the behavior very surprising. It might be worth documenting somewhere.