Unify admin callback checks and log queue job failures

This commit is contained in:
2026-02-15 01:20:55 +03:00
parent b54a094185
commit 7c56430f32
3 changed files with 25 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import asyncio
import logging
import time
from collections import deque
from typing import Awaitable, Callable, Any
@@ -25,6 +26,7 @@ _alert_cfg: dict[str, Any] = {
"last_sent": 0.0,
}
_cfg: dict[str, Any] | None = None
_logger = logging.getLogger("queue")
def _save_stats():
@@ -85,8 +87,18 @@ async def worker():
status = "ok"
try:
await job()
except Exception:
except Exception as e:
status = "err"
_logger.exception("Queue job failed: label=%s", label)
if _cfg:
try:
log_incident(
_cfg,
f"queue_job_failed label={label} error={type(e).__name__}: {e}",
category="queue",
)
except Exception:
pass
finally:
finished_at = time.time()
if _current_meta: