From 0deffdbc7496bcee67e98f9a3f414ee35f2441bf Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 30 Jul 2021 14:32:11 +0200 Subject: [PATCH] fix(python): do not set socket to nonblocking for wait_until_ready There's two udp calls in `UdpTransport._ping()`: - socket.sendall(b"PINGPING") -> this will be instanteous, AND it will raise if the receiving side is not listening. - socket.recv() -> this will wait for SOCKET_TIMEOUT seconds, but only in case the sendall() succeeded. This means that receiving side exists and we are now waiting until it's awake enough to respond. In conclusion, we avoid hammering emulator with PINGPINGs with a timeout so short we don't see an answer. This should avoid the problem occasionally seen in CI and described in #1668 --- python/src/trezorlib/transport/udp.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/src/trezorlib/transport/udp.py b/python/src/trezorlib/transport/udp.py index 447ae24986b..335e194346c 100644 --- a/python/src/trezorlib/transport/udp.py +++ b/python/src/trezorlib/transport/udp.py @@ -91,7 +91,6 @@ def find_by_path(cls, path: str, prefix_search: bool = False) -> "UdpTransport": def wait_until_ready(self, timeout: float = 10) -> None: try: self.open() - self.socket.settimeout(0) start = time.monotonic() while True: if self._ping():