mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 10:21:32 +00:00
Fix inotify event logs triggering themselves (infinite log recursion)
This commit is contained in:
parent
029f4a9eb2
commit
32e3c2860d
@ -1,6 +1,7 @@
|
||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||
# All Rights Reserved. See LICENSE file for details.
|
||||
|
||||
import logging
|
||||
from os.path import dirname
|
||||
|
||||
from watchdog.events import PatternMatchingEventHandler as PatternMatchingWatchdogEventHandler
|
||||
@ -12,6 +13,7 @@ from tfw.mixins import ObserverMixin, SupervisorLogMixin
|
||||
|
||||
class LogMonitor(ObserverMixin):
|
||||
def __init__(self, process_name):
|
||||
self.prevent_log_recursion()
|
||||
ObserverMixin.__init__(self)
|
||||
event_handler = SendLogWatchdogEventHandler(process_name)
|
||||
self.observer.schedule(
|
||||
@ -19,6 +21,11 @@ class LogMonitor(ObserverMixin):
|
||||
event_handler.path
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def prevent_log_recursion():
|
||||
# This is done to prevent inotify event logs triggering themselves (infinite log recursion)
|
||||
logging.getLogger('watchdog.observers.inotify_buffer').propagate = False
|
||||
|
||||
|
||||
class SendLogWatchdogEventHandler(PatternMatchingWatchdogEventHandler, SupervisorLogMixin):
|
||||
def __init__(self, process_name):
|
||||
|
Loading…
Reference in New Issue
Block a user