Repository navigation
Wake SSLStream handshake waiters when the handshake fails - #3583
Open
AboodFares wants to merge 1 commit into
Open
AboodFares wants to merge 1 commit into
AboodFares wants to merge 1 commit into
Conversation
If the task performing the lazy TLS handshake raised or was cancelled, _Once never set its done event, so a concurrent task waiting on the handshake (e.g. receive_some while another task is in send_all) slept forever. Always set the event, record failure in a flag, and raise BrokenResourceError for waiters and later fast-path callers. The original exception is not stored, avoiding reference cycles and mutated tracebacks. `done` still means the handshake succeeded, so attribute forwarders keep raising NeedHandshakeError after a failure. Fixes python-trio#3581. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3583 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19555 19625 +70
Branches 1330 1333 +3
===============================================
+ Hits 19555 19625 +70
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Fixes #3581.
If the lazy handshake fails or gets cancelled while another task is waiting on it (e.g. send_all + receive_some), the waiter hangs forever, because _Once only set the done event on success.
Changes:
Tests cover a failed handshake, a cancelled handshake, and _Once directly for the checkpoint=False path. All of them hang without the fix.