implicit pause

This commit is contained in:
Will McGugan
2025-09-29 15:18:36 +01:00
parent b3e1ef9899
commit 4e0f6f1d40
2 changed files with 6 additions and 3 deletions

View File

@@ -468,8 +468,10 @@ class MessagePump(metaclass=_MessagePumpMeta):
due to calling it within the node's own task.
"""
if self._task is None or asyncio.current_task() is self._task:
assert (
self._task is not None
), "Node must be running before calling wait_for_refresh"
if asyncio.current_task() is self._task:
return False
refreshed_event = asyncio.Event()
self.call_after_refresh(refreshed_event.set)

View File

@@ -434,6 +434,7 @@ class Pilot(Generic[ReturnType]):
widget_at = None
for chain in range(1, times + 1):
for mouse_event_cls in events:
await self.pause()
# Get the widget under the mouse before the event because the app might
# react to the event and move things around. We override on each iteration
# because we assume the final event in `events` is the actual event we care
@@ -453,8 +454,8 @@ class Pilot(Generic[ReturnType]):
# we patch the offset in there as well.
app.mouse_position = offset
screen._forward_event(event)
await self.pause()
await self.pause()
return widget is None or widget_at is target_widget
async def _wait_for_screen(self, timeout: float = 30.0) -> bool: