Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This was referenced Oct 24, 2026
chipkent
force-pushed
the
feat/ws-reconnect-options
branch
from
October 24, 2026 14:54
6ebec59 to
217eec5
Compare
chipkent
force-pushed
the
feat/ws-request-close
branch
from
October 24, 2026 14:54
f47a026 to
dbcc501
Compare
This was referenced Oct 24, 2026
close() is a coroutine that must run on connect()'s event loop. run() creates that loop itself, so another thread cannot stop a client started with run(): asyncio.run(client.close()) from another thread fails with "attached to a different loop". request_close() can be called from any thread and does not wait. It sets a flag and, while connect() runs, closes the connection through loop.call_soon_threadsafe(). connect() checks the flag before it reconnects and after a wait before reconnecting, so it returns instead, also with reconnect_on_close. An attempt to connect, or a wait before reconnecting, is not interrupted: connect() returns once it ends, without opening another connection. If connect() is not running, the next call returns at once. close() called while connect() runs now sets the same flag. Before, a close() during the wait before a reconnect (reconnect_backoff > 0) or during a connect or reconnect handshake found no open connection to close, and connect() went on to connect. A close() before connect() starts is unchanged: the next connect() proceeds. With the default reconnect_backoff of 0 there is no wait, so the only difference is a close() made during a connect or reconnect handshake.
chipkent
force-pushed
the
feat/ws-request-close
branch
from
October 24, 2026 15:16
dbcc501 to
e818c9c
Compare
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 #<issue: F2-close>
Builds on #23.
close()is a coroutine that must run onconnect()'s event loop.run()creates that loop itself, so another thread cannot stop a client started withrun():asyncio.run(client.close())from another thread fails with "attached to a different loop".New
request_close(), safe to call from any thread, and it does not wait:connect()runs, closes the connection throughloop.call_soon_threadsafe().connect()checks the flag before it reconnects and after a wait before reconnecting, and returns instead, also withreconnect_on_close.connect()returns once it ends, without opening another connection.connect()is not running, the next call returns at once.close()called whileconnect()runs now sets the same flag. Before, aclose()during the wait before a reconnect (#23'sreconnect_backoff), or during a connect or reconnect handshake, found no open connection to close, andconnect()connected anyway. Aclose()beforeconnect()starts is unchanged: the nextconnect()proceeds. With the defaultreconnect_backoff=0there is no wait, so the only difference is aclose()made during a connect or reconnect handshake.Tests
test_request_close.py: stopsrun()from another thread, stops reconnecting after a drop, makes a request beforeconnect()return without connecting, checks that aclose()beforeconnect()starts still lets it connect, and checks thatrequest_close()orclose()during the wait before a reconnect opens no new connection (the wait is patched, not timed).make testandmake lintpass on 3.10 and 3.14.