Fix flaky remote test on slow runners (quit mainloop when client finishes)#97
Merged
Conversation
…shes testRemote's _run_with_client ran the Tk mainloop for a fixed 1.5s window, then quit regardless of whether the client thread had finished. The only test whose client uses RemoteAppProxy (test_proxy_validates_against_signatures) makes three marshaled round-trips (connect -> remote_signatures -> add) instead of one, and on the slow ubuntu/py3.11 CI runner that consistently exceeded the window: the mainloop quit before add's task was serviced on the main thread, so the server-side future.result(timeout=30) timed out and the client got None. Quit as soon as the client thread finishes (polled on the main thread) instead of after a fixed delay; the queue keeps draining until the client is done, so a slow runner gets as long as it needs. The fixed time becomes a 5s safety net so a genuinely hung call cannot wedge the suite. Also makes the suite faster, since quick clients no longer wait out the full window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
ubuntu-latest / py3.11fails deterministically ontestRemote.TestRemoteServer.test_proxy_validates_against_signatures(it reproduced on a clean re-run), while all 10 other OS×Python combinations pass:Root cause
The test harness
_run_with_clientran the Tk mainloop for a fixed 1.5 s window and then quit unconditionally:Every remote call is marshaled onto the Tk main thread (
schedule_on_main_thread→run_main_queue), and the server blocks onfuture.result(timeout=30)until the main thread services it. Most tests do one round-trip. This is the only test whose client usesRemoteAppProxy, which does three (connect→remote_signatures→add) because it validates the call against the server's advertised signatures first. On the slow ubuntu-3.11 runner (full suite ~103 s there) the mainloop quit beforeadd's task was serviced, so the future timed out and the client receivedNone.Fix
Quit as soon as the client thread finishes (polled on the main thread via
after) instead of after a fixed delay. The queue keeps draining until the client is done, so a slow runner gets as long as it needs. The fixed time becomes a 5 s safety net so a genuinely hung call cannot wedge the suite.Applied to both identical copies of the harness (
TestRemoteServerandTestRemoteCommands).Result
🤖 Generated with Claude Code