file-filter's: provide stop function in order to explicitly delete/stop monitoring of each file.

pull/2019/merge
sebres 2018-01-15 18:00:15 +01:00
parent 81c86fa83f
commit 2bce0c5e3e
2 changed files with 11 additions and 1 deletions

View File

@ -1061,6 +1061,15 @@ class FileFilter(Filter):
ret.append(("File list", path))
return ret
def stop(self):
"""Stop monitoring of log-file(s)
"""
# stop files monitoring:
for path in self.__logs.keys():
self.delLogPath(path)
# stop thread:
super(Filter, self).stop()
##
# FileContainer class.
#

View File

@ -78,6 +78,7 @@ class FilterPyinotify(FileFilter):
self.__modified = False
# Pyinotify watch manager
self.__monitor = pyinotify.WatchManager()
self.__notifier = None
self.__watchFiles = dict()
self.__watchDirs = dict()
self.__pending = dict()
@ -240,7 +241,7 @@ class FilterPyinotify(FileFilter):
def _delFileWatcher(self, path):
try:
wdInt = self.__watchFiles.pop(path)
if not self._delWatch(wdInt): # pragma: no cover
if not self._delWatch(wdInt):
logSys.debug("Non-existing file watcher %r for file %s", wdInt, path)
logSys.debug("Removed file watcher for %s", path)
return True