From 3b40aed9397fbb7c3ff81eb1012b17ac739650dd Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Fri, 17 Apr 2026 11:29:42 +0000 Subject: [PATCH] fix(run): isolate command dispatch exceptions from detection loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Any exception in _dispatch_command (status, ss, etc.) was leaking out of the asyncio.QueueEmpty try/except, crashing _detection_loop and cancelling the poller — making the bot permanently unresponsive for the rest of the session. Separate the queue-empty check from the dispatch into two try blocks. Dispatch errors now log to audit + print to terminal + send a Telegram warn. Co-Authored-By: Claude Sonnet 4.6 --- src/atm/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/atm/main.py b/src/atm/main.py index 333b5f8..965fdd4 100644 --- a/src/atm/main.py +++ b/src/atm/main.py @@ -846,9 +846,15 @@ async def run_live_async(cfg, duration_s=None, capture_stub: bool = False) -> No while True: try: cmd = cmd_queue.get_nowait() - await _dispatch_command(cmd) except asyncio.QueueEmpty: break + try: + await _dispatch_command(cmd) + except Exception as _cmd_exc: + _msg = f"/{cmd.action}: {_cmd_exc}" + audit.log({"ts": time.time(), "event": "command_error", "action": cmd.action, "error": str(_cmd_exc)}) + print(f"ERR command_dispatch {_msg}", flush=True) + notifier.send(Alert(kind="warn", title=f"Eroare comandă /{cmd.action}", body=str(_cmd_exc))) await asyncio.sleep(cfg.loop_interval_s)