mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 07:11:56 +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
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from contextlib import suppress
|
||||
|
||||
from transitions import Machine, MachineError
|
||||
|
||||
@ -62,14 +63,12 @@ class FSMBase(Machine, CallbackMixin):
|
||||
)
|
||||
|
||||
if all(predicate_results):
|
||||
try:
|
||||
with suppress(AttributeError, MachineError):
|
||||
from_state = self.state
|
||||
self.trigger(trigger)
|
||||
self.update_event_log(from_state, trigger)
|
||||
return True
|
||||
except (AttributeError, MachineError):
|
||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||
return False
|
||||
if self.trigger(trigger):
|
||||
self.update_event_log(from_state, trigger)
|
||||
return True
|
||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||
|
||||
def update_event_log(self, from_state, trigger):
|
||||
self.event_log.append({
|
||||
|
Loading…
Reference in New Issue
Block a user