Repository navigation
fix(connect_tcp): synchronize server startup, client connections, and retries with terminal shutdown - #26
Merged
Conversation
Check the terminal flag before each outer connect attempt and return False when close wins between retries. Keep the existing local-port fallback and the handling of an already started connection attempt unchanged.
Record the control socket and ID of an acquired client port range. Serialize its release and ignore cleanup for another session or an already released reservation, so a late close cannot delete a reused ID. This does not defer range release until all borrowed ports are returned.
Record how to review the three parts of 90567ed against its parent without rewriting the current branch. Keep A2 gated on A1 review, regression coverage and API documentation. No product or test changes.
Distinguish a refused next attempt from a TCP request already in flight. The A0/B0 V0 baseline passed all nine targeted cases.
Document sequential ID reuse and its distinction from returning a borrowed port. The V0 regression preserves the replacement client’s record after a late close.
Exercise startup after stop, a listening but unpublished socket, a published session and a reader parked before registration, in threaded and asyncio modes. Verify fd retirement, peer EOF, same-address /clients and configuration deletion after the original call returns. Against the parent the refused-start, candidate-return and unregistered-socket cases each fail in both modes. A1: eight timing cases pass; both complete endpoint test files pass (48 cases) on Linux/Python 3.10.
Distinguish terminal refusal from normal exit and document same-address reuse without restarting the old instance. Preserve the historical E2 report. The Sphinx dummy build completed with two pre-existing warnings.
Add the integration half of A-S alongside the stopped-instance unit cases in 4c045a2. Verify replacement service and terminal cleanup before releasing the old caller or reader. The parent leaves the pending fd open in both modes and returns None for prepublication refusal. All eight A-S cases pass on the accepted tree; the published-session cases are positive controls.
Complete the documentation delivered with 1b7e117. Keep E2 historical results and Client in-flight behavior out of the Server acceptance claim.
Keep the original fd, EOF and same-address checks. Park the actual running store and observe real lock contention versus completed stop; inspect reader registration before teardown can erase it. Isolate saved progress and outbound logs. 4c045a2 contains the stopped-instance unit test; the first socket integration cases landed in 347cdfb. The final A-S set is ten cases: pre-A1 eight fail and both published-session controls pass; all ten pass on A1. Default progress and outbound-log fixture bytes remain unchanged. Targeted ty check passed.
A0 checks between attempts. A caller past that check can still issue a TCP request after close returns. Link to the generated method reference for exact results.
Explain that the allocator records the then-current control socket, not necessarily a delayed announcement’s source. Duplicate numeric announcements can overwrite that single slot.
Keep lifecycle handoff guidance in the Server API guide and exact outcomes in the method reference and A1 change note. The note identifies the shared configuration wrapper, both accept paths and cleanup lock boundary. Final Sphinx dummy build exited 0 with the two pre-existing warnings; no change to the historical E2 report.
Track the candidate socket before bind/connect so close() can retire it. Publish the control socket and reader together. If close() wins during mode negotiation, return False without starting key exchange or recovery. Wake negotiation and retry waits on close(). Wait one second before retrying a refused or timed-out connection, but keep the immediate fallback to an OS-assigned port when the fixed local port is unavailable. The private dialing and publication helpers do not change public signatures. Prior verification on this exact file: 13 V2 regressions, four adjacent regressions and 30 isolated probes passed on Linux. The full suite and native Windows/macOS were not run for A2.
Exercise the A2 admission, retry and fixed-port fallback paths. Hold an ordinary connector after the peer accepts and verify that close retires its fd before the caller is released. Check mode refusal, interruptible backoff and stale recovery against the real control-session lifecycle. Test-only changes across three modules; no product structure or interface changes. Prior Linux/Python 3.10 verification: all 38 targeted cases passed. Of the 17 new cases, 13 failed on the pre-A2 parent and four controls passed. No full-suite or native Windows/macOS run.
Update the Client API guide and A2 change note. Distinguish a TCP request observed by the peer from a published session, EOF before a mode announcement from ordinary disconnect, and immediate local-port fallback from a delayed retry. Documentation only; no product structure or interface changes. Prior Sphinx dummy build completed with two pre-existing warnings.
A single one-second backoff may call Condition.wait() more than once with the time remaining before its deadline. Record the timeout passed to wait_for() and its predicate outcome instead of counting those individual waits. Keep the exact interval and close-cancellation checks. Linux: all eight targeted cases passed with early returns injected; three conditions re-waited with a sub-second remainder. Native Windows Actions has not been rerun. No product code or CI configuration changed.
A reused address in server.clients does not prove that the client has published its replacement socket. Wait for new control sockets on both ends before checking automatic upload and download recovery. Keep the original timeout, fixed-port assertion and byte-for-byte file checks. Linux: both tests passed with client publication held until after server registration. Native Windows Actions has not been rerun.
F18-Ray
force-pushed
the
fix_close_setup_race
branch
from
December 1, 2026 15:35
a220fef to
5916f5e
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Pull Request
Summary
<What this PR does and which problem it solves, in two or three sentences.>
Change type
Checklist
pytest)ruff check)# noqa/# type: ignore)Documentation impact
Design decisions
Design note summary (if any)
<Fill this in when "implicit assumptions to record" is ticked; or link the
docs/source/changes/PR-*.mdnote.>