From 0a052806c7e1ce35d33bf3f32d14ab41cb5cc091 Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 28 Jan 2020 16:15:06 +0100 Subject: [PATCH] python: kill emulator if it doesn't become ready in time this fixes a problem in upgrade-test, when one emulator fails to come up and then blocks all other tests. the CI task will still be failed, but at least we'll know at a glance that it is a timeout problem --- python/src/trezorlib/_internal/emulator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/src/trezorlib/_internal/emulator.py b/python/src/trezorlib/_internal/emulator.py index fc2898f534..01a26236c5 100644 --- a/python/src/trezorlib/_internal/emulator.py +++ b/python/src/trezorlib/_internal/emulator.py @@ -97,7 +97,7 @@ class Emulator: elapsed = time.monotonic() - start if elapsed >= timeout: - raise RuntimeError("Can't connect to emulator") + raise TimeoutError("Can't connect to emulator") time.sleep(0.1) finally: @@ -135,7 +135,12 @@ class Emulator: return self.process = self.launch_process() - self.wait_until_ready() + try: + self.wait_until_ready() + except TimeoutError: + # Assuming that after the default 30-second timeout, the process is stuck + self.process.kill() + raise (self.profile_dir / "trezor.pid").write_text(str(self.process.pid) + "\n") (self.profile_dir / "trezor.port").write_text(str(self.port) + "\n")