fix(yt-long): cap kick concurrency and expose status in health

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-20 10:22:49 -05:00
parent 9732647037
commit 161dc58b57
2 changed files with 5 additions and 0 deletions

View File

@ -235,6 +235,7 @@ async def health() -> dict[str, Any]:
try:
out["monitor"] = await asyncio.to_thread(monitor.status)
out["shorts"] = await asyncio.to_thread(shorts_pipeline.status)
out["yt_long"] = await asyncio.to_thread(yt_long_pipeline.status)
out["youtube_monitor"] = await asyncio.to_thread(yt_monitor.status)
except Exception as exc:
out["status_error"] = str(exc)[:120]

View File

@ -394,12 +394,16 @@ class YtLongPipeline:
self._task = None
async def kick_pending_records(self, ids: list[str] | None = None) -> int:
cfg = db.get_settings_map()
max_rec = max(1, int(cfg.get("yt_long_max_concurrent") or 1))
pending = yt_long_db.list_pending_yt_long_jobs(limit=20)
if ids:
want = {str(x) for x in ids}
pending = [j for j in pending if str(j.get("id") or "") in want]
n = 0
for job in pending:
if self._active_records >= max_rec:
break
claimed = yt_long_db.claim_yt_long_job_record(str(job.get("id") or ""))
if not claimed:
continue