Skip to content

Commit 28d2ea4

Browse files
committed
Add timeouts to get_rington and _get_canned_messages
1 parent d7d9c72 commit 28d2ea4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

meshtastic/node.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ def get_ringtone(self):
448448
self._sendAdmin(
449449
p1, wantResponse=True, onResponse=self.onResponseRequestRingtone
450450
)
451-
while self.gotResponse is False:
451+
start_time = time.time()
452+
timeout = 2
453+
while not self.gotResponse:
454+
if time.time() - start_time > timeout:
455+
logging.warning("Timeout waiting for ringtone plugin response")
456+
return None
452457
time.sleep(0.1)
453458

454459
logging.debug(f"self.ringtone:{self.ringtone}")
@@ -521,7 +526,13 @@ def get_canned_message(self):
521526
wantResponse=True,
522527
onResponse=self.onResponseRequestCannedMessagePluginMessageMessages,
523528
)
524-
while self.gotResponse is False:
529+
530+
start_time = time.time()
531+
timeout = 2
532+
while not self.gotResponse:
533+
if time.time() - start_time > timeout:
534+
logging.warning("Timeout waiting for canned message plugin response")
535+
return None
525536
time.sleep(0.1)
526537

527538
logging.debug(

0 commit comments

Comments
 (0)