chore(python): re-introduce sleep when starting Tropic emulator
What changed, and why it matters
This is a small developer-only change that adds a 2-second wait when starting a Tropic emulator used in Trezor's Python test tooling. It fixes a timing/race condition where the emulator appears ready to accept connections but still needs a moment before it can actually handle requests. There is no security issue here.
No security action needed. Treat as a normal reliability/testing improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies python/src/trezorlib/_internal/emulator.py in the TropicModel startup loop. Previously, the code broke out of the connection-retry loop as soon as a TCP connection to 127.0.0.1:self.port succeeded. The change keeps that success check but adds a fixed time.sleep(2) before breaking, with a comment explaining that the model sometimes needs up to two extra seconds after listening before it correctly processes requests. This is a robustness fix for local emulator startup synchronization, not a vulnerability patch.
Changed components
python/src/trezorlib/_internal/emulator.pyTropicModel emulator startup logicInspect captured patch +6 / −1
diff --git a/python/src/trezorlib/_internal/emulator.py b/python/src/trezorlib/_internal/emulator.py
index 1c772e4e2..b06fdc963 100644
--- a/python/src/trezorlib/_internal/emulator.py
+++ b/python/src/trezorlib/_internal/emulator.py
@@ -123,7 +123,12 @@ class TropicModel:
while True:
try:
with socket.create_connection(("127.0.0.1", self.port), timeout=1):
- break # if we can connect to the model, it means it is ready
+ # seems that even if the model is listening for connections
+ # it sometimes needs up to 2 seconds more
+ # before it actually correctly processes requests
+ # TODO: https://github.com/trezor/trezor-firmware/pull/6128
+ time.sleep(2)
+ break
except OSError:
pass
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.