fix(run): isolate command dispatch exceptions from detection loop
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user