fixes gh-3635: avoid sporadic error in pyinotify backend if pending file deleted in other thread; restore correct logging in tests

pull/3402/merge
sebres 2023-11-22 20:16:53 +01:00
commit 44fa2959e7
3 changed files with 5 additions and 3 deletions

View File

@ -173,7 +173,9 @@ class FilterPyinotify(FileFilter):
if not chkpath(path): # not found - prolong for next time
if retardTM < 60: retardTM *= 2
if minTime > retardTM: minTime = retardTM
self.__pending[path][0] = retardTM
try:
self.__pending[path][0] = retardTM
except KeyError: pass
continue
logSys.log(logging.MSG, "Log presence detected for %s %s",
"directory" if isDir else "file", path)

View File

@ -61,6 +61,7 @@ class ConfigReaderTest(unittest.TestCase):
def tearDown(self):
"""Call after every test case."""
shutil.rmtree(self.d)
super(ConfigReaderTest, self).tearDown()
def _write(self, fname, value=None, content=None):
# verify if we don't need to create .d directory

View File

@ -54,7 +54,6 @@ class Socket(LogCaptureTestCase):
def setUp(self):
"""Call before every test case."""
LogCaptureTestCase.setUp(self)
super(Socket, self).setUp()
self.server = AsyncServer(self)
sock_fd, sock_name = tempfile.mkstemp('fail2ban.sock', 'f2b-socket')
@ -68,7 +67,7 @@ class Socket(LogCaptureTestCase):
if self.serverThread:
self.server.stop(); # stop if not already stopped
self._stopServerThread()
LogCaptureTestCase.tearDown(self)
super(Socket, self).tearDown()
@staticmethod
def proceed(message):