summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-08 14:18:13 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-08 14:18:13 -0800
commita01e01dc8281403bb37211d6f2f8c1071441e401 (patch)
treea5ede8c2b8d61139c2fafa5c0bb6eb3ecd8f175e
parentca7fc08d5219dc6c33f67d4e39317aade4490575 (diff)
downloadpanel-a01e01dc8281403bb37211d6f2f8c1071441e401.tar.gz
panel-a01e01dc8281403bb37211d6f2f8c1071441e401.tar.xz
fix potential negative sleeps
-rwxr-xr-xpanel.py6
1 files changed, 4 insertions, 2 deletions
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()