Skip to content

Commit 46e81d3

Browse files
authored
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 1b038e0)
1 parent 948171b commit 46e81d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Lib/logging/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,14 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
815815

816816
if isinstance(address, str):
817817
self.unixsocket = True
818-
self._connect_unixsocket(address)
818+
# Syslog server may be unavailable during handler initialisation.
819+
# C's openlog() function also ignores connection errors.
820+
# Moreover, we ignore these errors while logging, so it not worse
821+
# to ignore it also here.
822+
try:
823+
self._connect_unixsocket(address)
824+
except OSError:
825+
pass
819826
else:
820827
self.unixsocket = False
821828
if socktype is None:

0 commit comments

Comments
 (0)