bpo-29808: SysLogHandler: Do not fail if initial connect to syslog fa… · python/cpython@1b038e0 (original) (raw)

Original file line number Diff line number Diff line change
@@ -815,7 +815,14 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
815 815
816 816 if isinstance(address, str):
817 817 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
819 826 else:
820 827 self.unixsocket = False
821 828 if socktype is None: