Refactor watchdog Observer handling to a mixin

This commit is contained in:
Kristóf Tóth
2018-04-14 20:36:43 +02:00
parent b082279916
commit 586c435cc2
4 changed files with 23 additions and 21 deletions

View File

@ -3,3 +3,4 @@
from .supervisor_mixin import SupervisorMixin
from .callback_mixin import CallbackMixin
from .observer_mixin import ObserverMixin

View File

@ -0,0 +1,16 @@
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
# All Rights Reserved. See LICENSE file for details.
from watchdog.observers import Observer
class ObserverMixin:
def __init__(self):
self.observer = Observer()
def watch(self):
self.observer.start()
def stop(self):
self.observer.stop()
self.observer.join()