From 34047cf3ec263ff43d7f6c4d4883d42e72400156 Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 30 Jul 2021 14:14:51 +0200 Subject: [PATCH] Revert "feat(python): give the emulator a little more time to respond to ping" This reverts commit ae0da5e24593c01da5955c374b24178157dda9dc. It seems that there was no good reason for the change in the first place. --- python/.changelog.d/1565.added | 1 - python/src/trezorlib/transport/udp.py | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 python/.changelog.d/1565.added diff --git a/python/.changelog.d/1565.added b/python/.changelog.d/1565.added deleted file mode 100644 index dc9859302a..0000000000 --- a/python/.changelog.d/1565.added +++ /dev/null @@ -1 +0,0 @@ -Wait up to 1 second for emulator responses. diff --git a/python/src/trezorlib/transport/udp.py b/python/src/trezorlib/transport/udp.py index 5275e229d3..447ae24986 100644 --- a/python/src/trezorlib/transport/udp.py +++ b/python/src/trezorlib/transport/udp.py @@ -24,7 +24,6 @@ from . import TransportException from .protocol import ProtocolBasedTransport, ProtocolV1 SOCKET_TIMEOUT = 10 -TRY_PATH_TIMEOUT = 1 LOG = logging.getLogger(__name__) @@ -60,12 +59,15 @@ class UdpTransport(ProtocolBasedTransport): def _try_path(cls, path: str) -> "UdpTransport": d = cls(path) try: - d.wait_until_ready(timeout=TRY_PATH_TIMEOUT) - return d - except Exception as e: - raise TransportException( - "No Trezor device found at address {}".format(d.get_path()) - ) from e + d.open() + if d._ping(): + return d + else: + raise TransportException( + "No Trezor device found at address {}".format(d.get_path()) + ) + finally: + d.close() @classmethod def enumerate(cls) -> Iterable["UdpTransport"]: