]> granicus.if.org Git - python/commitdiff
bpo-29808: SysLogHandler: Do not fail if initial connect to syslog failed (#663)...
authorКоренберг Марк <socketpair@gmail.com>
Fri, 17 Mar 2017 15:25:05 +0000 (20:25 +0500)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 17 Mar 2017 15:25:05 +0000 (15:25 +0000)
Lib/logging/handlers.py

index 7d779734f37b0d229fff800e45294db9d9cb62d7..2356f8d3d2d8ce96663a65be481a9038115c638e 100644 (file)
@@ -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: