Use power of LazyInitialise to replace ObserverMixin.__init__()

This commit is contained in:
Kristóf Tóth 2018-06-01 14:06:40 +02:00
parent 9f3a3b501f
commit cebacb15e6
4 changed files with 5 additions and 5 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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()