From a01e01dc8281403bb37211d6f2f8c1071441e401 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 8 Mar 2024 14:18:13 -0800 Subject: fix potential negative sleeps --- panel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'panel.py') diff --git a/panel.py b/panel.py index 59d4874..77a6a51 100755 --- a/panel.py +++ b/panel.py @@ -146,7 +146,8 @@ class ModDate(Mod): self.refreshing = False self.repaint(flush=True) - self.e.wait(1 - (dt.microsecond / 1000000)) + if (t := 1 - (dt.microsecond / 1000000)) > 0: + self.e.wait(t) self.e.clear() def process_cmd(self, cmd): @@ -418,7 +419,8 @@ class IntervalTimer(): if now > self.func_next_time.get(func, 0): func() self.func_next_time[func] = now - (now % ival) + ival - time.sleep(min(self.func_next_time.values()) - time.time()) + if (t := min(self.func_next_time.values()) - time.time()) > 0: + time.sleep(t) class ModInterval(Mod): timer = IntervalTimer() -- cgit v1.2.3-70-g09d2