mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 08:11:32 +00:00
Fix fsm.update messages being thiggered without a state change
This commit is contained in:
parent
269cab691e
commit
c8d4080ef5
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
from transitions import Machine, MachineError
|
from transitions import Machine, MachineError
|
||||||
|
|
||||||
@ -62,14 +63,12 @@ class FSMBase(Machine, CallbackMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if all(predicate_results):
|
if all(predicate_results):
|
||||||
try:
|
with suppress(AttributeError, MachineError):
|
||||||
from_state = self.state
|
from_state = self.state
|
||||||
self.trigger(trigger)
|
if self.trigger(trigger):
|
||||||
self.update_event_log(from_state, trigger)
|
self.update_event_log(from_state, trigger)
|
||||||
return True
|
return True
|
||||||
except (AttributeError, MachineError):
|
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def update_event_log(self, from_state, trigger):
|
def update_event_log(self, from_state, trigger):
|
||||||
self.event_log.append({
|
self.event_log.append({
|
||||||
|
Loading…
Reference in New Issue
Block a user