Bring sync client to feature parity - #1748
Open
aaugustin wants to merge 7 commits into
Open
Conversation
aaugustin
force-pushed
the
sync-client-feature-parity
branch
3 times, most recently
from
August 19, 2026 06:13
c49b1ff to
18cfa5d
Compare
aaugustin
force-pushed
the
sync-client-feature-parity
branch
from
August 20, 2026 06:57
18cfa5d to
359a1be
Compare
This usage was never shown in examples, but it was clearly described in the documentation and it must exist in the wild. Add a flag for backwards compatibility. While the name implies that it should go away in the long run, it isn't immediately deprecated. Its name provide light deterrence, which is enough for now.
aaugustin
force-pushed
the
sync-client-feature-parity
branch
2 times, most recently
from
August 21, 2026 07:26
3664bad to
af045ec
Compare
aaugustin
marked this pull request as ready for review
August 21, 2026 07:27
aaugustin
force-pushed
the
sync-client-feature-parity
branch
from
August 21, 2026 07:28
af045ec to
55e36e8
Compare
aaugustin
force-pushed
the
sync-client-feature-parity
branch
from
August 21, 2026 07:32
55e36e8 to
4c020d3
Compare
aaugustin
dismissed
a stale review
August 21, 2026 07:33
no idea who this is, this user doesn't even exist
There was a problem hiding this comment.
Pull request overview
Adds redirect handling, automatic reconnection, and connection API parity to the synchronous client.
Changes:
- Adds sync reconnection and redirect support.
- Introduces context-manager migration behavior and Unix/TCP improvements.
- Expands parity tests and documentation.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/websockets/sync/client.py |
Implements reconnect and redirect APIs. |
src/websockets/sync/connection.py |
Adds legacy-usage warnings. |
src/websockets/sync/server.py |
Restricts TCP options to IP sockets. |
src/websockets/trio/client.py |
Refines connection and Unix handling. |
src/websockets/asyncio/client.py |
Refactors direct connection setup. |
tests/sync/test_client.py |
Tests new sync client behavior. |
tests/sync/test_server.py |
Uses shared server address handling. |
tests/sync/test_router.py |
Updates sync redirect coverage. |
tests/sync/server.py |
Refactors sync test helpers. |
tests/trio/test_client.py |
Expands lifecycle and Unix tests. |
tests/trio/test_server.py |
Updates listener address handling. |
tests/trio/test_router.py |
Shares router test configuration. |
tests/trio/server.py |
Refactors Trio server helpers. |
tests/asyncio/test_client.py |
Expands lifecycle parity tests. |
tests/asyncio/test_router.py |
Shares router test configuration. |
docs/reference/sync/client.rst |
Documents new sync APIs. |
docs/reference/features.rst |
Marks sync parity features. |
docs/project/changelog.rst |
Records new sync capabilities. |
Makefile |
Changes the default test target. |
Suppressed comments (1)
src/websockets/sync/client.py:696
- This example is for the synchronous API, so
connect()isn't awaitable. Copying it produces invalid usage (and aTypeErrorif placed in an async function); call it directly as the warning text and new tests do.
websocket = await connect(..., legacy=True)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| path: str | None = None, | ||
| uri: str | None = None, | ||
| *, | ||
| legacy: bool | None = None, |
|
|
||
| tests: | ||
| python -m unittest | ||
| python -m unittest tests/sync/test_client.py -v |
| """ | ||
| Similar to :func:`connect`, with support for automatic reconnection. | ||
|
|
||
| :func:`reconnect` can also be treated as an infinite asynchronous iterator |
|
|
||
| .. autofunction:: unix_reconnect | ||
|
|
||
| .. autofunction:: process_exception |
Comment on lines
862
to
+864
| def unix_connect( | ||
| path: str | None = None, | ||
| uri: str | None = None, | ||
| **kwargs: Any, | ||
| ) -> ClientConnection: | ||
| *args: Any, legacy: bool | None = None, **kwargs: Any | ||
| ) -> ClientConnection | reconnect: |
Comment on lines
+702
to
+703
| def maybe_raise_legacy_warning(self) -> None: | ||
| pass # see override in ClientConnection |
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.
No description provided.