From: Vinay Sajip Date: Fri, 17 Mar 2017 19:52:56 +0000 (+0000) Subject: bpo-29808: Do not fail in SysLogHandler constructor if syslog isn't available. (... X-Git-Tag: v3.6.2rc1~307 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46e81d3345b979f835740a228857906dca0f59c0;p=thirdparty%2FPython%2Fcpython.git bpo-29808: Do not fail in SysLogHandler constructor if syslog isn't available. (#696) bpo-29808: SysLogHandler: Do not fail if initial connect to syslog failed. (cherry picked from commit 1b038e073807ecb6fd176edaf3386a8e3205416e) --- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 7d779734f37b..2356f8d3d2d8 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -815,7 +815,14 @@ class SysLogHandler(logging.Handler): if isinstance(address, str): self.unixsocket = True - self._connect_unixsocket(address) + # Syslog server may be unavailable during handler initialisation. + # C's openlog() function also ignores connection errors. + # Moreover, we ignore these errors while logging, so it not worse + # to ignore it also here. + try: + self._connect_unixsocket(address) + except OSError: + pass else: self.unixsocket = False if socktype is None: