From e4a880e435c1ca15ec03ff509477fb8269a87cc5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 9 Nov 2022 17:46:18 +0000 Subject: [PATCH] trezor: use lower device-enumeration timeout for udp transport This transport IIUC is only used for the trezor emulator. The default timeout is 10 seconds. Every time we enumerate hw devices, we also enumerate trezor devices, including scanning for the udp transport. For some reason, recently on Windows, sporadically, this scan keeps hitting the timeout for me. Quite annoying, as I might not even be testing trezor (and I am certainly not testing using the trezor emulator on Windows...), but scanning to test other plugins. Probably overkill to have a 10 sec timeout for contacting localhost anyway. --- electrum/plugins/trezor/trezor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/electrum/plugins/trezor/trezor.py b/electrum/plugins/trezor/trezor.py index 9dbfd5cac..03aa61f3d 100644 --- a/electrum/plugins/trezor/trezor.py +++ b/electrum/plugins/trezor/trezor.py @@ -160,6 +160,11 @@ class TrezorPlugin(HW_PluginBase): @runs_in_hwd_thread def enumerate(self): + # Set lower timeout for UDP enumeration (used for emulator). + # The default of 10 sec is very long, and I often hit it for some reason on Windows (no emu running), + # blocking the whole enumeration. + from trezorlib.transport.udp import UdpTransport + trezorlib.transport.udp.SOCKET_TIMEOUT = 1 # If there is a bridge, prefer that. # On Windows, the bridge runs as Admin (and Electrum usually does not), # so the bridge has better chances of finding devices. see #5420