diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 867ef4ebc7600a0..042c4f8a9197227 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -582,17 +582,24 @@ def send(self, s): This function allows for partial sends which can happen when the network is busy. """ - if self.sock is None: - self.createSocket() - #self.sock can be None either because we haven't reached the retry - #time yet, or because we have reached the retry time and retried, - #but are still unable to connect. - if self.sock: + attempt = True + while True: + if self.sock is None: + attempt = False + self.createSocket() + # self.sock can be None either because we haven't reached the retry + # time yet, or because we have reached the retry time and retried, + # but are still unable to connect. + if self.sock is None: + break try: self.sock.sendall(s) except OSError: #pragma: no cover self.sock.close() self.sock = None # so we can call createSocket next time + if attempt: + continue + break def makePickle(self, record): """