Commit e9c8deab authored by Guido Trotter's avatar Guido Trotter
Browse files

ErrorLoggingAsyncNotifier



This mixes AsyncNotifier with GanetiBaseAsyncoreDispatcher to provide an
AsyncNotifier which will log errors, rather than bail out.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent b11780bb
......@@ -117,7 +117,8 @@ class ConfdConfigurationReloader(object):
self.inotify_handler = asyncnotifier.SingleFileEventHandler(self.wm,
self.OnInotify,
cfg_file)
self.notifier = asyncnotifier.AsyncNotifier(self.wm, self.inotify_handler)
notifier_class = asyncnotifier.ErrorLoggingAsyncNotifier
self.notifier = notifier_class(self.wm, self.inotify_handler)
self.timer_handle = None
self._EnableTimer()
......
......@@ -31,6 +31,7 @@ try:
except ImportError:
import pyinotify
from ganeti import daemon
from ganeti import errors
# We contributed the AsyncNotifier class back to python-pyinotify, and it's
......@@ -65,6 +66,16 @@ class AsyncNotifier(asyncore.file_dispatcher):
self.notifier.process_events()
class ErrorLoggingAsyncNotifier(AsyncNotifier,
daemon.GanetiBaseAsyncoreDispatcher):
"""An asyncnotifier that can survive errors in the callbacks.
We define this as a separate class, since we don't want to make AsyncNotifier
diverge from what we contributed upstream.
"""
class SingleFileEventHandler(pyinotify.ProcessEvent):
"""Handle modify events for a single file.
......
......@@ -57,8 +57,8 @@ class TestSingleFileEventHandler(testutils.GanetiTestCase):
self.cbk[i],
self.chk_files[i])
for i in range(len(self.NOTIFIERS))]
self.notifiers = [asyncnotifier.AsyncNotifier(self.wms[i],
self.ihandler[i])
self.notifiers = [asyncnotifier.ErrorLoggingAsyncNotifier(self.wms[i],
self.ihandler[i])
for i in range(len(self.NOTIFIERS))]
# TERM notifier is enabled by default, as we use it to get out of the loop
self.ihandler[self.NOTIFIER_TERM].enable()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment