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()
except ImportError:
import pyinotify
+from ganeti import daemon
from ganeti import errors
# We contributed the AsyncNotifier class back to python-pyinotify, and it's
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.
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()