baseimage-tutorial-framework/lib/tfw/builtins/fsm_aware_event_handler.py

23 lines
661 B
Python
Raw Normal View History

from abc import ABC
2019-06-28 13:11:02 +00:00
from tfw.components import FSMAware
from tfw.networking import Scope
2019-06-28 13:11:02 +00:00
from .event_handler import EventHandler
2019-06-28 13:11:02 +00:00
class FSMAwareEventHandler(EventHandler, FSMAware, ABC):
# pylint: disable=abstract-method
"""
Abstract base class for EventHandlers which automatically
keep track of the state of the TFW FSM.
"""
2019-06-28 13:11:02 +00:00
def __init__(self, key, scope=Scope.ZMQ):
EventHandler.__init__(self, key, scope=scope)
FSMAware.__init__(self)
self.subscribe('fsm_update')
def dispatch_handling(self, message):
if not self.refresh_on_fsm_update(message):
super().dispatch_handling(message)