remove RobotClient.async_client property to eliminate cross-loop foot-gun#6
Merged
Merged
Conversation
…-gun The property returned self._inner — the AsyncRobotClient bound to RobotClient's private background loop. Reaching for it from another loop and awaiting one of its methods produced a cryptic "Queue is bound to a different event loop" deep inside _request_ok_raw. Worse, _run()'s error message steered users toward the trap: "use AsyncRobotClient and `await` the method instead" got read as "grab the one hanging off my sync client" rather than "construct a fresh one in this loop." - Delete the async_client property (zero non-test callers across this repo and Waldo-Commander; re-added in 8cc47dc as part of a typed-stub revert). - Tighten _run()'s error message to point at constructing a fresh AsyncRobotClient in the calling loop. - Update the two test sites that monkeypatched client.async_client._request to use client._inner._request directly — they were already patching a private method, so the change is honest.
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
RobotClient.async_clientreturnsself._inner— the sameAsyncRobotClientthe sync wrapper bound to its private background loop. Reaching for it from
any other loop (e.g. a NiceGUI page handler) and awaiting one of its
methods produces a cryptic
RuntimeError: <Queue ...> is bound to a different event loopdeep inside_request_ok_raw.Worse,
_run()'s error message currently steers people toward the trap:"use AsyncRobotClient and
awaitthe method instead" gets read as "grabthe one hanging off my sync client" rather than "construct a fresh one
in this loop."
Fix
async_clientproperty. Zero non-test callers across thisrepo and Waldo-Commander.
_run()'s error message to point at constructing a freshAsyncRobotClientin the calling loop.client.async_client._requestto use
client._inner._requestdirectly — they were already patching aprivate method, so the change is honest.