mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-25 05:51:31 +00:00
Use power of LazyInitialise to replace ObserverMixin.__init__()
This commit is contained in:
parent
9f3a3b501f
commit
cebacb15e6
@ -16,7 +16,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class DirectoryMonitor(ObserverMixin):
|
||||
def __init__(self, directories):
|
||||
ObserverMixin.__init__(self)
|
||||
self.eventhandler = IdeReloadWatchdogEventHandler()
|
||||
for directory in directories:
|
||||
self.observer.schedule(self.eventhandler, directory, recursive=True)
|
||||
|
@ -37,7 +37,6 @@ class HistoryMonitor(CallbackMixin, ObserverMixin, ABC):
|
||||
"""
|
||||
def __init__(self, histfile):
|
||||
CallbackMixin.__init__(self)
|
||||
ObserverMixin.__init__(self)
|
||||
self.histfile = histfile
|
||||
self._history = []
|
||||
self._last_length = len(self._history)
|
||||
|
@ -14,7 +14,6 @@ from tfw.mixins import ObserverMixin, SupervisorLogMixin
|
||||
class LogMonitor(ObserverMixin):
|
||||
def __init__(self, process_name, log_tail=0):
|
||||
self.prevent_log_recursion()
|
||||
ObserverMixin.__init__(self)
|
||||
event_handler = SendLogWatchdogEventHandler(process_name, log_tail=log_tail)
|
||||
self.observer.schedule(
|
||||
event_handler,
|
||||
|
@ -3,10 +3,13 @@
|
||||
|
||||
from watchdog.observers import Observer
|
||||
|
||||
from tfw.decorators import LazyInitialise
|
||||
|
||||
|
||||
class ObserverMixin:
|
||||
def __init__(self):
|
||||
self.observer = Observer()
|
||||
@LazyInitialise
|
||||
def observer(self):
|
||||
return Observer()
|
||||
|
||||
def watch(self):
|
||||
self.observer.start()
|
||||
|
Loading…
Reference in New Issue
Block a user