Commit ad88650c authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Reopen log file only once after SIGHUP

Commit b6fa9a44

 added a re-openable log handler. The log file is
reopened when a daemon is sent a HUP signal. Due to a bug in the code,
fixed by this patch, the log file would be reopened for every single log
message thereafter.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 638ac34b
......@@ -70,6 +70,9 @@ class _ReopenableLogHandler(logging.handlers.BaseRotatingHandler):
# TODO: Handle errors? = open(self.baseFilename, "a")
# Don't reopen on the next message
self._reopen = False
def RequestReopen(self):
"""Register a request to reopen the file.
......@@ -35,7 +35,7 @@ import testutils
class TestLogHandler(unittest.TestCase):
def test(self):
def testNormal(self):
tmpfile = tempfile.NamedTemporaryFile()
handler = utils.log._ReopenableLogHandler(
......@@ -84,6 +84,10 @@ class TestLogHandler(unittest.TestCase):
# Write another message, should reopen
for _ in range(4):"Test message INFO")
# Flag must be reset
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment