From fd362b5fefb47288b52492bc8a3c600bac7aa6b2 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 30 May 2021 20:51:00 +0200 Subject: [PATCH] Fixed: Program not stalling when system time is changed and regular update of current timezone --- bpytop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bpytop.py b/bpytop.py index 218cf19..53af186 100755 --- a/bpytop.py +++ b/bpytop.py @@ -1662,6 +1662,7 @@ class Box: _b_mem_h: int redraw_all: bool buffers: List[str] = [] + c_counter: int = 0 clock_on: bool = False clock: str = "" clock_len: int = 0 @@ -1701,6 +1702,10 @@ class Box: @classmethod def draw_clock(cls, force: bool = False): if not "cpu" in cls.boxes or not cls.clock_on: return + cls.c_counter += 1 + if cls.c_counter > 3600 / (Config.update_ms / 1000): + time.tzset() + cls.c_counter = 0 out: str = "" if force: pass elif Term.resized or strftime(CONFIG.draw_clock) == cls.clock: return @@ -4975,7 +4980,11 @@ class Timer: @classmethod def left(cls) -> float: - return cls.timestamp + (CONFIG.update_ms / 1000) - time() + t_left: float = cls.timestamp + (CONFIG.update_ms / 1000) - time() + if t_left > CONFIG.update_ms / 1000: + cls.stamp() + return CONFIG.update_ms / 1000 + return t_left @classmethod def finish(cls):