Repository navigation
feat(python): expose client disconnect and shutdown - #4288
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
jiengup
left a comment
There was a problem hiding this comment.
LGTM
covered all the acceptance criterias stated in the original issue.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4288 +/- ##
=========================================
Coverage 87.75% 87.76%
+ Complexity 1576 1575 -1
=========================================
Files 1289 1290 +1
Lines 227123 227156 +33
Branches 190575 190544 -31
=========================================
+ Hits 199323 199364 +41
+ Misses 23096 23087 -9
- Partials 4704 4705 +1
🚀 New features to boost your workflow:
|
slbotbm
left a comment
There was a problem hiding this comment.
Let's add the following tests:
- IggyClient(addr) → disconnect() → disconnect() → connect() → ping() works.
- shutdown() → shutdown() → connect() must fail
Otherwise looks good
|
/ready |
|
/skill team-review-slim |
There was a problem hiding this comment.
Summary: PR 4288 adds disconnect() and shutdown() to the Python client with docstrings and lifecycle tests. The wrappers and the tests track the SDK, but two documented contracts do not hold: an auto-login client reconnects on its own after disconnect(), and a later disconnect() makes shutdown() non-terminal.
Counts: critical 0, warning 2, nit 1, simplification 0
This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.
|
/ready |
|
/request-review @slbotbm |
hubcio
left a comment
There was a problem hiding this comment.
not blocking, and all pre-existing in the rust sdk - #4287 does not cover these yet:
- warning: a reconnect already running when
shutdown()is called setsConnectedoverShutdownand signs in again once the server is back (core/sdk/src/tcp/tcp_client.rs:705). QUIC and websocket do the same with auto-login. - warning:
disconnect()returnsOkwhile a connect is in flight, and that connect later leaves the client connected, even without auto-login (core/sdk/src/tcp/tcp_client.rs:1281). same root cause as the one above. - warning: over TLS, a failed close after a peer reset returns before
set_state(Shutdown), so the heartbeat brings the client back (core/sdk/src/tcp/tcp_client.rs:1308). websocket ignores that error and always setsShutdown. - warning: a redial during
endpoint.wait_idle()keeps QUICdisconnect()blocked for as long as the new connection lives (core/sdk/src/quic/quic_client.rs:980).
separate from this PR, and worth its own issue: TCP, QUIC and websocket clients keep an event receiver nobody reads, so publish_event blocks forever at event 1001 (core/sdk/src/tcp/tcp_client.rs:574). set_overflow(true) on the sender fixes it.
hubcio
left a comment
There was a problem hiding this comment.
prev "Request changes" was by mistake.
|
/ready |
Which issue does this PR address?
Closes #4163
Rationale
The Rust
Clienttrait hasdisconnect()andshutdown(), but the PythonIggyClientonly hadconnect(). Thus a Python caller cannot close a connection to connect again later, and cannot release the client without dropping it.What changed?
Now
IggyClienthas the async methodsdisconnect()andshutdown(). Both methods call the Rust client directly, and repeated calls are safe. The behavior depends on the transport:disconnect()closes the connection, and the client can connect again. The sign-in fromlogin_user()is lost, thus the caller must log in again afterconnect(). A client with auto-login credentials logs in again onconnect().shutdown()closes the connection and releases the client. Aftershutdown(), requests fail withRuntimeError.The Rust SDK has lifecycle problems that also affect these methods. They are tracked in #4287, and this PR does not change the Rust SDK:
disconnect(). Thedisconnect()docstring describes this behavior, and the tests use clients without auto-login.shutdown(). The test forconnect()aftershutdown()marks WebSocketxfail(strict=True), thus the test fails when the fix for Rust SDK: the heartbeat undoes disconnect(), and a WebSocket client connects after shutdown() #4287 lands and the mark can go.disconnect()aftershutdown()makes the client reusable on every transport. For this reason, theshutdown()docstring does not say that the call is terminal.Local Execution
I used Zed in devcontainer mode. The server and the tests ran in the devcontainer, and
prekran on macOS.Passed:
cargo fmtandcargo clippy --all-targets --all-features -- -D warningsinforeign/python.Passed:
cargo run --bin stub_gen, thenruff formatandruff check --fix. The stub diff contains only the two new methods and their docstrings.Passed: the lifecycle tests against a local
iggy-serverbuilt from this branch, with 18 passed and 1 expected failure:Passed: pre-commit hooks with
SKIP=web-lint prek run --all-files. Every hook passed. I skippedweb-lintbecause this PR does not changeweb/.AI Usage