From 161dc58b579d34882455bc4e62346c62bc0e43fe Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 20 Aug 2026 10:22:49 -0500 Subject: [PATCH] fix(yt-long): cap kick concurrency and expose status in health Co-authored-by: Cursor --- backend/app/main.py | 1 + backend/app/yt_long_pipeline.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/backend/app/main.py b/backend/app/main.py index 700bd2f..25827c3 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -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] diff --git a/backend/app/yt_long_pipeline.py b/backend/app/yt_long_pipeline.py index 8ee6661..141f1f9 100644 --- a/backend/app/yt_long_pipeline.py +++ b/backend/app/yt_long_pipeline.py @@ -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