Skip to content

Add timeouts to get_ringtone and get_canned_messages #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions meshtastic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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(
Expand Down
Loading