fix: jsocket reconnect lifecycle 2.0.2#27
Merged
Conversation
fix: break out socket timeouts fix: reduce possible fd leak
fix(jsocket): harden socket lifecycle and server factory handoff test(jsocket): add regression test for reconnecting from a closed fd without backoff chore(release): bump version to 2.0.2
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens jsocket client/server socket lifecycle behavior to avoid unnecessary reconnect backoff after JsonClient.close(), and improves server-side cleanup and accept-loop behavior while bumping the package version to 2.0.2.
Changes:
JsonClient.connect()now recreates sockets proactively when the existing fd is closed, avoiding a guaranteed initial failure/backoff after reuse._send()treatsOSError/zero-byte sends as a broken connection and closes cleanly; server listening is made idempotent via_is_listening.tserverwakeup-socket fallback cleanup andServerFactoryaccept/worker-spawn sequencing are improved; adds a regression test and bumps version.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
jsocket/jsocket_base.py |
Adds closed-fd detection + socket recreation in connect(), hardens _send(), and tracks/reset server listening state. |
jsocket/tserver.py |
Improves wakeup socket fallback cleanup, adjusts accept-loop logging, and spawns workers only after successful accept/handoff. |
tests/test_additional_coverage.py |
Adds regression coverage for reconnect-after-close avoiding the backoff sleep path. |
jsocket/_version.py |
Bumps package version to 2.0.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR hardens jsocket connection lifecycle handling and removes an avoidable reconnect penalty after JsonClient.close(). It also
improves server-side socket/wakeup cleanup and bumps the package version to 2.0.2.
What Changed
before attempting connect().
Behavioral Impact
guaranteed initial failure + delay.
Validation
test_additional_coverage.py::test_client_connect_recreates_closed_socket_without_backoff (1 passed, 1 skipped in sandboxed env).
test_additional_coverage.py::test_serverfactory_accept_timeout_and_close_branches (1 passed, 1 skipped in sandboxed env).