feat: Update Extraction model and service to support deferred service detection

This commit is contained in:
JSC
2025-07-29 10:50:50 +02:00
parent 9b5f83eef0
commit e3fcab99ae
4 changed files with 227 additions and 176 deletions

View File

@@ -1,7 +1,6 @@
"""Background extraction processor for handling extraction queue."""
import asyncio
from typing import Set
from sqlmodel.ext.asyncio.session import AsyncSession
@@ -19,7 +18,7 @@ class ExtractionProcessor:
def __init__(self) -> None:
"""Initialize the extraction processor."""
self.max_concurrent = settings.EXTRACTION_MAX_CONCURRENT
self.running_extractions: Set[int] = set()
self.running_extractions: set[int] = set()
self.processing_lock = asyncio.Lock()
self.shutdown_event = asyncio.Event()
self.processor_task: asyncio.Task | None = None
@@ -71,7 +70,7 @@ class ExtractionProcessor:
)
async def _process_queue(self) -> None:
"""Main processing loop that handles the extraction queue."""
"""Process the extraction queue in the main processing loop."""
logger.info("Starting extraction queue processor")
while not self.shutdown_event.is_set():
@@ -161,7 +160,7 @@ class ExtractionProcessor:
logger.exception("Error processing extraction %d: %s", extraction_id, e)
def _on_extraction_completed(self, extraction_id: int, task: asyncio.Task) -> None:
"""Callback when an extraction task is completed."""
"""Handle completion of an extraction task."""
# Remove from running set
self.running_extractions.discard(extraction_id)