mirror of
https://github.com/python/cpython.git
synced 2025-10-01 04:42:10 +00:00
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 1b038e0738
)
This commit is contained in:
parent
948171bf99
commit
46e81d3345
1 changed files with 8 additions and 1 deletions
|
@ -815,7 +815,14 @@ class SysLogHandler(logging.Handler):
|
||||||
|
|
||||||
if isinstance(address, str):
|
if isinstance(address, str):
|
||||||
self.unixsocket = True
|
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:
|
else:
|
||||||
self.unixsocket = False
|
self.unixsocket = False
|
||||||
if socktype is None:
|
if socktype is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue