Skip to content

bpo-29808: Do not fail in SysLogHandler constructor if syslog isn't available. #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 17, 2017
Merged
9 changes: 8 additions & 1 deletion Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,14 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),

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:
Expand Down