pyinotify-backend: stability fix for sporadically errors in multi-threaded environment (without lock)

pull/1557/head
sebres 2016-09-09 10:56:35 +02:00
parent 8c4eebc3e3
commit 4404642fa3
1 changed files with 14 additions and 10 deletions

View File

@ -119,14 +119,15 @@ class FilterPyinotify(FileFilter):
logSys.debug("Added file watcher for %s", path) logSys.debug("Added file watcher for %s", path)
def _delFileWatcher(self, path): def _delFileWatcher(self, path):
wdInt = self.__watches[path] try:
wd = self.__monitor.rm_watch(wdInt) wdInt = self.__watches.pop(path)
if wd[wdInt]: wd = self.__monitor.rm_watch(wdInt)
del self.__watches[path] if wd[wdInt]:
logSys.debug("Removed file watcher for %s", path) logSys.debug("Removed file watcher for %s", path)
return True return True
else: except KeyError: # pragma: no cover
return False pass
return False
## ##
# Add a log file path # Add a log file path
@ -158,8 +159,11 @@ class FilterPyinotify(FileFilter):
if k.startswith(path_dir + pathsep)]): if k.startswith(path_dir + pathsep)]):
# Remove watches for the directory # Remove watches for the directory
# since there is no other monitored file under this directory # since there is no other monitored file under this directory
wdInt = self.__watches.pop(path_dir) try:
self.__monitor.rm_watch(wdInt) wdInt = self.__watches.pop(path_dir)
self.__monitor.rm_watch(wdInt)
except KeyError: # pragma: no cover
pass
logSys.debug("Removed monitor for the parent directory %s", path_dir) logSys.debug("Removed monitor for the parent directory %s", path_dir)
# pyinotify.ProcessEvent default handler: # pyinotify.ProcessEvent default handler: