mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 16:11:32 +00:00
Move @with_monitor_paused decoartor to directory_monitor.py
This commit is contained in:
parent
1a4d88668a
commit
095c818a36
@ -1,5 +1,6 @@
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler as FileSystemWatchdogEventHandler
|
||||
from functools import wraps
|
||||
|
||||
from tfw.networking.event_handlers.server_connector import ServerUplinkConnector
|
||||
from tfw.components.decorators import RateLimiter
|
||||
@ -65,3 +66,13 @@ class WebideReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
|
||||
log.debug(event)
|
||||
key = 'webide'
|
||||
self.uplink.send(key, {'data': {'command': 'reload'}})
|
||||
|
||||
|
||||
def with_monitor_paused(fun):
|
||||
@wraps(fun)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
if self.monitor:
|
||||
with self.monitor.pauser:
|
||||
return fun(self, *args, **kwargs)
|
||||
return fun(self, *args, **kwargs)
|
||||
return wrapper
|
||||
|
@ -1,8 +1,8 @@
|
||||
from functools import wraps
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from tfw.event_handler_base import TriggerlessEventHandler
|
||||
from tfw.components.mixins import SupervisorMixin
|
||||
from tfw.components.directory_monitor import with_monitor_paused
|
||||
from tfw.config.logs import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -25,16 +25,7 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
||||
self.monitor = dirmonitor
|
||||
self.processmanager = ProcessManager()
|
||||
|
||||
def _with_monitor_paused(fun):
|
||||
@wraps(fun)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
if self.monitor:
|
||||
with self.monitor.pauser:
|
||||
return fun(self, *args, **kwargs)
|
||||
return fun(self, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
@_with_monitor_paused
|
||||
@with_monitor_paused
|
||||
def handle_event(self, key, message):
|
||||
try:
|
||||
data = message['data']
|
||||
|
Loading…
Reference in New Issue
Block a user