Skip to content

Commit

Permalink
fix(python): do not set socket to nonblocking for wait_until_ready
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matejcik committed Jul 30, 2021
1 parent 5deab6a commit 0deffdb
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion python/src/trezorlib/transport/udp.py
Expand Up @@ -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():
Expand Down

0 comments on commit 0deffdb

Please sign in to comment.