From 81e38a85b0e99a875dd33b394fb5f0afa9d56876 Mon Sep 17 00:00:00 2001 From: thiswillbeyourgithub Date: Fri, 7 Jul 2023 20:03:17 +0200 Subject: [PATCH] fix: remove any alarm given an action Signed-off-by: thiswillbeyourgithub --- wasp/wasp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wasp/wasp.py b/wasp/wasp.py index d505326..bc09d3b 100644 --- a/wasp/wasp.py +++ b/wasp/wasp.py @@ -350,13 +350,13 @@ class Manager(): def cancel_alarm(self, time, action): """Unqueue an alarm.""" + alarms = self._alarms try: - if time is None: - for i, al in enumerate(self._alarms): - if self._alarms[i][1] == action: - self._alarms.remove(self._alarms[i]) + if not time: + time_to_remove = [al[0] for al in alarms if al[1] == action] + [alarms.remove((t, action)) for t in time_to_remove] else: - self._alarms.remove((time, action)) + alarms.remove((time, action)) except: return False return True