summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-03-17 19:54:50 (GMT)
committerGitHub <noreply@github.com>2017-03-17 19:54:50 (GMT)
commite59af55c28b657cdf57c71a7b0837c9e9f4b2a31 (patch)
treee45747336a23d36310a7b27c7d2a4143ddbd8724
parent41b4a2189f29daae008e57f799a30890643d191f (diff)
downloadcpython-e59af55c28b657cdf57c71a7b0837c9e9f4b2a31.zip
cpython-e59af55c28b657cdf57c71a7b0837c9e9f4b2a31.tar.gz
cpython-e59af55c28b657cdf57c71a7b0837c9e9f4b2a31.tar.bz2
bpo-29808: Do not fail in SysLogHandler constructor if syslog isn't available. (#695)
bpo-29808: SysLogHandler: Do not fail if initial connect to syslog failed. (cherry picked from commit 1b038e073807ecb6fd176edaf3386a8e3205416e)
-rw-r--r--Lib/logging/handlers.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index c39a56f..e346331 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -803,7 +803,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: