This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Kazutaka.Morita
Recipients Kazutaka.Morita
Date 2012-06-25.11:29:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1340623771.92.0.68954184969.issue15179@psf.upfronthosting.co.za>
In-reply-to
Content
If we stop a syslog daemon when running the following program, it
leads to an infinite loop.

==
#!/usr/bin/env python

import eventlet
from logging.handlers import SysLogHandler
import time
import logging

eventlet.patcher.monkey_patch(all=False, socket=True)

logger = logging.getLogger('log')
logger.addHandler(SysLogHandler('/dev/log'))

while True:
    print "send a message to logger"
    logger.error("syslog test")
    time.sleep(1)
==

It is because there is a close leak in the python logging module, and
SysLogHandler continues to send a log message against the closed
connection forever.

The following patch seems to fix this problem:

diff -r 3b5545ba6432 Lib/logging/handlers.py
--- a/Lib/logging/handlers.py	Wed Jun 13 22:15:26 2012 -0400
+++ b/Lib/logging/handlers.py	Mon Jun 25 20:27:46 2012 +0900
@@ -801,7 +801,11 @@
         except socket.error:
             self.socket.close()
             self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-            self.socket.connect(address)
+            try:
+                self.socket.connect(address)
+            except socket.error:
+                self.socket.close()
+                raise
 
     def encodePriority(self, facility, priority):
         """
History
Date User Action Args
2012-06-25 11:29:31Kazutaka.Moritasetrecipients: + Kazutaka.Morita
2012-06-25 11:29:31Kazutaka.Moritasetmessageid: <1340623771.92.0.68954184969.issue15179@psf.upfronthosting.co.za>
2012-06-25 11:29:31Kazutaka.Moritalinkissue15179 messages
2012-06-25 11:29:30Kazutaka.Moritacreate