Przeglądaj źródła

Fix crash from syslog handler during log reopen request. Closes #201

Mike Naberezny 12 lat temu
rodzic
commit
08ecd4c533
3 zmienionych plików z 16 dodań i 0 usunięć
  1. 3 0
      CHANGES.txt
  2. 3 0
      supervisor/loggers.py
  3. 10 0
      supervisor/tests/test_loggers.py

+ 3 - 0
CHANGES.txt

@@ -17,6 +17,9 @@ Next release
   support, it was decided to remove this feature.  A warning was added to the
   documentation that two processes may not log to the same file.
 
+- Fixed a bug where supervisord would crash if the syslog handler was used
+  and supervisord received SIGUSR2 (log reopen request).
+
 3.0b1 (2012-09-10)
 ------------------
 

+ 3 - 0
supervisor/loggers.py

@@ -303,6 +303,9 @@ class SyslogHandler(Handler):
     def close(self):
         pass
 
+    def reopen(self):
+        pass
+
     def emit(self, record):
         try:
             params = record.asdict()

+ 10 - 0
supervisor/tests/test_loggers.py

@@ -318,6 +318,16 @@ class SyslogHandlerTests(HandlerTests, unittest.TestCase):
         handler.emit(record)
         syslog.syslog.assert_called_with('hello!')
 
+    @mock.patch('syslog.syslog', MockSysLog())
+    def test_close(self):
+        handler = self._makeOne()
+        handler.close()  # no-op for syslog
+
+    @mock.patch('syslog.syslog', MockSysLog())
+    def test_reopen(self):
+        handler = self._makeOne()
+        handler.reopen()  # no-op for syslog
+
     @mock.patch('syslog.syslog', MockSysLog())
     def test_emit_unicode_noerror(self):
         handler = self._makeOne()