Skip to content

Commit 502f738

Browse files
committed
remove RobotClient.async_client property to eliminate cross-loop foot-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.
1 parent ea4afc9 commit 502f738

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

‎parol6/client/sync_client.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _run(coro: Coroutine[Any, Any, T]) -> T:
102102
# A loop is running in this thread; blocking would be unsafe.
103103
raise RuntimeError(
104104
"RobotClient was used while an event loop is running.\n"
105-
"Use AsyncRobotClient and `await` the method instead."
105+
"Construct an AsyncRobotClient in this loop and `await` it instead."
106106
)
107107

108108

@@ -166,11 +166,6 @@ def __enter__(self) -> "RobotClient":
166166
def __exit__(self, exc_type, exc, tb) -> None:
167167
self.close()
168168

169-
@property
170-
def async_client(self) -> AsyncRobotClient:
171-
"""Access the underlying async client if you need it."""
172-
return self._inner
173-
174169
# Expose common configuration attributes
175170
@property
176171
def host(self) -> str:

‎tests/unit/test_conversions.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_pose_identity_translation(monkeypatch):
2929
result = _pose_result(mat)
3030

3131
mock_request = AsyncMock(return_value=result)
32-
monkeypatch.setattr(client.async_client, "_request", mock_request)
32+
monkeypatch.setattr(client._inner, "_request", mock_request)
3333

3434
pose_rpy = client.pose()
3535
assert pose_rpy is not None
@@ -49,7 +49,7 @@ def test_pose_malformed_payload(monkeypatch):
4949
client = RobotClient()
5050

5151
mock_request = AsyncMock(return_value=PoseResultStruct(pose=[1, 2, 3]))
52-
monkeypatch.setattr(client.async_client, "_request", mock_request)
52+
monkeypatch.setattr(client._inner, "_request", mock_request)
5353

5454
pose_rpy = client.pose()
5555
assert pose_rpy is None

0 commit comments

Comments
 (0)