New submission from Kazutaka Morita <morita.kazut...@gmail.com>: 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): """ ---------- components: Library (Lib) messages: 163939 nosy: Kazutaka.Morita priority: normal severity: normal status: open title: An infinite loop happens when we use SysLogHandler with eventlet type: behavior versions: Python 2.7, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15179> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com