Skip to content

Commit 36f90ad

Browse files
committed
docs(core): document why _waiting_screen doesn't send ButtonRequests
[no changelog]
1 parent 6df8926 commit 36f90ad

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

core/src/trezor/wire/protocol_common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ async def _waiting_screen(raise_on_cancel: type[Exception] | None) -> None:
152152
) as obj:
153153
# Block until the user confirmation.
154154
# Don't use `interact` to avoid cancelling current workflow.
155-
await Layout(obj).get_result()
155+
layout = Layout(obj)
156+
layout.start()
157+
# This task doesn't have access to I/O context - see `ButtonRequestHandler.join()`.
158+
# Therefore, the new layout won't start its own ButtonRequest hander,
159+
# avoiding interference with the existing layout (the one we are waiting for).
160+
assert layout.button_request_handler is None
161+
await layout.get_result()
156162

157163
if raise_on_cancel:
158164
raise raise_on_cancel()
@@ -212,6 +218,7 @@ async def join(self) -> None:
212218
self.box.put(None, replace=True)
213219

214220
# Wait for the ButtonRequest handler to finish (or user cancellation)
221+
# `_waiting_screen` layout won't have an I/O context, since it runs in a separate task.
215222
await loop.race(self.is_done, _waiting_screen(self.raise_on_cancel))
216223

217224
async def _handle(self, ack_callback: AckCallback) -> None:

0 commit comments

Comments
 (0)