GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-84532: Reopen the socket in SocketHandler.send() when sending fails by serhiy-storchaka · Pull Request #154540 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 23, 2026

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

  • Issue: SocketHandler silently drops log messages on re-connect #84532

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka @claude
pythongh-84532: Reopen the socket in SocketHandler.send() when sendin…
a222437
…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) <[email protected]>
@serhiy-storchaka
serhiy-storchaka requested a review from vsajip as a code owner July 23, 2026 13:41
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 23, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jul 23, 2026
SocketHandler silently drops log messages on re-connect #84532
Open
@serhiy-storchaka @claude
pythongh-84532: Close the accepted connections in test_reconnect
fdcdb4f
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) <[email protected]>
vsajip
vsajip reviewed Aug 2, 2026
View reviewed changes
Comment thread Lib/logging/handlers.py
# retry time yet, or because we have reached the retry time
# and retried, but are still unable to connect.
if self.sock is None:
return

@vsajip vsajip Aug 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

How about a break here? I prefer not to do early returns - e.g. if we were ever to add something after the for statement, we wouldn't need to revisit this line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/logging/handlers.py
try:
self.sock.sendall(s)
except OSError: #pragma: no cover
return

@vsajip vsajip Aug 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

As comment above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vsajip vsajip vsajip left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@serhiy-storchaka @vsajip
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.