Unify admin callback checks and log queue job failures
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user