Repository navigation
fix(rpcclient): stop WebDAV mount when the target disconnects - #450
Merged
Merged
Conversation
The `webdav`/`rpcdav` runner blocked on a fresh `asyncio.Event()` that nothing ever set, so when the target went away (device reboot, killed rpcserver, dropped connection) the WebDAV server, local mount, and process all stayed up serving errors until Ctrl-C. Wait on the RPC connection instead: `ClientEvent.TERMINATED` unblocks the moment an in-flight request fails, and a periodic liveness probe (getpid) catches a disconnect that happens while the mount is idle. On disconnect we print a message and run the existing teardown (unmount, stop server, close client). Claude-Session: https://claude.ai/code/session_01X7BxNXzz1dJmtZngoj5kab
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.
Problem
The
webdav/rpcdavrunner blocked on a freshasyncio.Event()that nothing ever set:So when the target went away — device reboot, killed
rpcserver, dropped connection — the WebDAV server, the local mount, and the process all stayed up serving errors until the user hit Ctrl-C.(Mirrors pymobiledevice3's
webdav: Close the server when the device disconnects.)Fix
Wait on the RPC connection instead of a dead event:
ClientEvent.TERMINATED(already emitted byCoreClient.rpc_callonConnectionError) unblocks the instant an in-flight WebDAV request fails.getpid, every 5 s) catches a disconnect that happens while the mount is idle and no request is in flight — rpc-project has no background reader, so an idle drop is otherwise invisible.On disconnect we print
Connection to <host> lost; stopping.and run the existing teardown (unmount, stop server, close client). Ctrl-C behaviour is unchanged.Verification
test_wait_for_disconnect_returns_on_terminated_event(notifier path) andtest_wait_for_disconnect_detects_idle_disconnect_via_heartbeat(probe path).tests/test_webdav.pypasses (25 passed) against a liverpcserver_ios;pyrightclean.TERMINATEDnotification returns immediately without waiting for the probe.https://claude.ai/code/session_01X7BxNXzz1dJmtZngoj5kab