diff --git a/lib/tfw/components/directory_monitor.py b/lib/tfw/components/directory_monitor.py index ba423be..3ad6732 100644 --- a/lib/tfw/components/directory_monitor.py +++ b/lib/tfw/components/directory_monitor.py @@ -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) diff --git a/lib/tfw/components/history_monitor.py b/lib/tfw/components/history_monitor.py index d5586a7..67bfc3b 100644 --- a/lib/tfw/components/history_monitor.py +++ b/lib/tfw/components/history_monitor.py @@ -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) diff --git a/lib/tfw/components/log_monitor.py b/lib/tfw/components/log_monitor.py index d7672d1..d8d1825 100644 --- a/lib/tfw/components/log_monitor.py +++ b/lib/tfw/components/log_monitor.py @@ -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, diff --git a/lib/tfw/mixins/observer_mixin.py b/lib/tfw/mixins/observer_mixin.py index 4101d96..198c405 100644 --- a/lib/tfw/mixins/observer_mixin.py +++ b/lib/tfw/mixins/observer_mixin.py @@ -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()