Skip to content

gh-84532: Reopen the socket in SocketHandler.send() when sending fails#154540

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:fix-sockethandler-reconnect
Open

gh-84532: Reopen the socket in SocketHandler.send() when sending fails#154540
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:fix-sockethandler-reconnect

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

SocketHandler.send() dropped the record whose sending failed and reconnected only on the next record, so after the connection was closed (for example after an idle timeout) it lost more records than necessary.

It now reopens the socket and sends the record again, like SysLogHandler.emit() has done for the Unix socket since 2.5.

This does not make SocketHandler lossless over TCP: the first record sent after the connection is closed still succeeds locally and is lost when the reset arrives, which cannot be detected. But it stops dropping the following record, whose send actually fails.

🤖 Generated with Claude Code

…g fails

It dropped the record whose send failed and reconnected only on the next
record.  Now it reopens the socket and sends the record again.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The test left the server-side connections unclosed, which regrtest reported
as an altered environment (ResourceWarning: unclosed socket).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant