Skip to content

remove RobotClient.async_client property to eliminate cross-loop foot-gun#6

Merged
Jepson2k merged 1 commit into
mainfrom
drop-sync-async_client-property
May 13, 2026
Merged

remove RobotClient.async_client property to eliminate cross-loop foot-gun#6
Jepson2k merged 1 commit into
mainfrom
drop-sync-async_client-property

Conversation

@Jepson2k
Copy link
Copy Markdown
Owner

Problem

RobotClient.async_client returns self._inner — the same AsyncRobotClient
the 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 loop deep inside _request_ok_raw.

Worse, _run()'s error message currently steers people toward the trap:
"use AsyncRobotClient and await the method instead" gets read as "grab
the one hanging off my sync client" rather than "construct a fresh one
in this loop."

Fix

  • Delete the async_client property. Zero non-test callers across this
    repo and Waldo-Commander.
  • 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.

…-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.
@Jepson2k Jepson2k marked this pull request as ready for review May 13, 2026 23:28
@Jepson2k Jepson2k merged commit 15f02ca into main May 13, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant