diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-03-08 14:18:13 -0800 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-03-08 14:18:13 -0800 |
commit | a01e01dc8281403bb37211d6f2f8c1071441e401 (patch) | |
tree | a5ede8c2b8d61139c2fafa5c0bb6eb3ecd8f175e /panel.py | |
parent | ca7fc08d5219dc6c33f67d4e39317aade4490575 (diff) | |
download | panel-a01e01dc8281403bb37211d6f2f8c1071441e401.tar.gz panel-a01e01dc8281403bb37211d6f2f8c1071441e401.tar.xz |
fix potential negative sleeps
Diffstat (limited to 'panel.py')
-rwxr-xr-x | panel.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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() |