Skip to content

Commit

Permalink
feat(python): give the emulator a little more time to respond to ping
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik committed May 6, 2021
1 parent 7ca67cc commit ae0da5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions python/.changelog.d/1565.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wait up to 1 second for emulator responses.
16 changes: 7 additions & 9 deletions python/src/trezorlib/transport/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .protocol import ProtocolBasedTransport, ProtocolV1

SOCKET_TIMEOUT = 10
TRY_PATH_TIMEOUT = 1

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -59,15 +60,12 @@ def find_debug(self) -> "UdpTransport":
def _try_path(cls, path: str) -> "UdpTransport":
d = cls(path)
try:
d.open()
if d._ping():
return d
else:
raise TransportException(
"No Trezor device found at address {}".format(d.get_path())
)
finally:
d.close()
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

@classmethod
def enumerate(cls) -> Iterable["UdpTransport"]:
Expand Down

0 comments on commit ae0da5e

Please sign in to comment.