1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-13 17:00:59 +00:00

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
This commit is contained in:
matejcik 2020-01-28 16:15:06 +01:00
parent 72537e3c3a
commit 0a052806c7

View File

@ -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")