From 28d2ea4d61791f4c2fe0dbde4d4af0cb5f3746cd Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Sun, 3 Aug 2025 23:22:33 -0700 Subject: [PATCH] Add timeouts to get_rington and _get_canned_messages --- meshtastic/node.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meshtastic/node.py b/meshtastic/node.py index e6bd3ca6..18d86887 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -448,7 +448,12 @@ def get_ringtone(self): self._sendAdmin( p1, wantResponse=True, onResponse=self.onResponseRequestRingtone ) - while self.gotResponse is False: + start_time = time.time() + timeout = 2 + while not self.gotResponse: + if time.time() - start_time > timeout: + logging.warning("Timeout waiting for ringtone plugin response") + return None time.sleep(0.1) logging.debug(f"self.ringtone:{self.ringtone}") @@ -521,7 +526,13 @@ def get_canned_message(self): wantResponse=True, onResponse=self.onResponseRequestCannedMessagePluginMessageMessages, ) - while self.gotResponse is False: + + start_time = time.time() + timeout = 2 + while not self.gotResponse: + if time.time() - start_time > timeout: + logging.warning("Timeout waiting for canned message plugin response") + return None time.sleep(0.1) logging.debug(