Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this code will retry connection once, straight away, if the handler was previously connected but an error occurs when actually sending the event. In the case where the reason for the error is that the remote has gone offline, how likely is that reconnection attempt to succeed? Isn't the remote going offline for a period the case described in the issue?


def makePickle(self, record):
"""
Expand Down