From 91e3cb2c5c2950c40d9973971a2801eab7aa8719 Mon Sep 17 00:00:00 2001 From: NotoriousPyro Date: Fri, 11 Sep 2026 11:34:36 +0100 Subject: [PATCH] fix potential negative calculation crash --- stonkfly/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stonkfly/cli.py b/stonkfly/cli.py index 3c7ba9b..a242d7e 100644 --- a/stonkfly/cli.py +++ b/stonkfly/cli.py @@ -275,8 +275,11 @@ def main(): count += 1 if not a.fast and (not a.steps or count < a.steps): until = started + settings.interval_seconds - while time.monotonic() < until and not (out / "STOP").exists(): - time.sleep(min(1, until - time.monotonic())) + while not (out / "STOP").exists(): + remaining = until - time.monotonic() + if remaining <= 0: + break + time.sleep(min(1, remaining)) except KeyboardInterrupt: print("Stopped; run state preserved.", flush=True) except Exception as e: