sleep a little bit in error case (to get around time-related errors, e.g. something like log-rotate, etc.)

pull/1539/head
sebres 2016-09-05 16:37:32 +02:00
parent 6454d0cd75
commit 1d6b546658
2 changed files with 5 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import logging
import os
import re
import sys
import time
from .failmanager import FailManagerEmpty, FailManager
from .ipdns import DNSUtils, IPAddr
@ -443,8 +444,10 @@ class Filter(JailThread):
except Exception as e:
logSys.error("Failed to process line: %r, caught exception: %r", line, e,
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
# incr error counter, stop processing this :
# incr error counter, stop processing (going idle) after 100th error :
self.__errors += 1
# sleep a little bit (to get around time-related errors):
time.sleep(self.sleeptime)
if self.__errors >= 100:
logSys.error("Too many errors at once (%s), going idle", self.__errors)
self.__errors //= 2

View File

@ -605,6 +605,7 @@ class LogFileMonitor(LogCaptureTestCase):
self.assertLogged('Unable to open %s' % self.name)
def testErrorProcessLine(self):
self.filter.sleeptime /= 1000.0
## produce error with not callable processLine:
_org_processLine = self.filter.processLine
self.filter.processLine = None