Skip to content

Fix rejected handshake cleanup in threading server#1729

Closed
Sanjays2402 wants to merge 1 commit into
python-websockets:mainfrom
Sanjays2402:fix/threading-handshake-rejection
Closed

Fix rejected handshake cleanup in threading server#1729
Sanjays2402 wants to merge 1 commit into
python-websockets:mainfrom
Sanjays2402:fix/threading-handshake-rejection

Conversation

@Sanjays2402

Copy link
Copy Markdown

The threading server treated an intentional HTTP rejection as a successful handshake and relied on an assertion to stop before the connection handler. That assertion was swallowed in normal mode and removed under python -O, where the handler ran on a closed connection.

This returns explicitly for a rejected handshake, closes and joins the receive thread, and adds a regression check that detects the internal assertion. Fixes #1722.

Return explicitly when a process hook rejects the opening handshake instead
of relying on an assertion that is swallowed or removed under optimization.

Fixes python-websockets#1722.
@aaugustin

Copy link
Copy Markdown
Member

Duplicate of #1726.

@aaugustin

Copy link
Copy Markdown
Member

I prefer the approach to testing from #1726; it's more straightforward and consistent with pre-existing tests.

@aaugustin aaugustin closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rejecting a handshake raises a silenced AssertionError in the threading server

2 participants