diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 95e23a8b78b..93aa50ea832 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -882,6 +882,7 @@ def emit(self, record): try: self.socket.send(msg) except socket.error: + self.socket.close() self._connect_unixsocket(self.address) self.socket.send(msg) elif self.socktype == socket.SOCK_DGRAM: diff --git a/Misc/NEWS b/Misc/NEWS index d6c151ff8f5..251804dd526 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,8 @@ Core and Builtins Library ------- +- Issue #17981: Closed socket on error in SysLogHandler. + - Fix typos in the multiprocessing module. - Issue #17754: Make ctypes.util.find_library() independent of the locale.