luplo.core.worker ================= .. py:module:: luplo.core.worker .. autoapi-nested-parse:: Unified background worker for sync jobs and glossary term extraction. Runs as ``lp worker start`` (Local mode) or inside the FastAPI server lifespan (Remote mode). Uses PG LISTEN/NOTIFY with a 60-second fallback poll to pick up work. Channels: - ``luplo_sync_jobs`` — notified when ``enqueue_sync`` creates/updates a job. - ``luplo_new_items`` — notified when a new item is created (for glossary candidate extraction). Post-v0.5. Attributes ---------- .. autoapisummary:: luplo.core.worker.logger luplo.core.worker.POLL_INTERVAL_SECONDS Functions --------- .. autoapisummary:: luplo.core.worker.run_worker Module Contents --------------- .. py:data:: logger .. py:data:: POLL_INTERVAL_SECONDS :value: 60 .. py:function:: run_worker(pool: psycopg_pool.AsyncConnectionPool) -> None :async: Main worker loop. Runs until cancelled. Listens for PG notifications on ``luplo_sync_jobs`` and falls back to polling every 60 seconds. Each iteration claims ready sync jobs and processes them. :param pool: Open connection pool to use for job queries.