Round 3 fixes: cancelled polling, aggregator invalid_count, filter state, scheduler atomicity, HTTP exception handler, tests

This commit is contained in:
祀梦
2026-04-05 10:20:23 +08:00
parent 49e440cb41
commit dc5f050683
32 changed files with 321 additions and 163 deletions

View File

@@ -1,6 +1,6 @@
"""调度器服务 - 定时触发全量验证"""
import asyncio
from typing import Optional
from typing import Optional, Any
from app.core.execution.executor import JobExecutor
from app.core.execution.job import ValidateAllJob
@@ -17,9 +17,11 @@ class SchedulerService:
def __init__(
self,
executor: JobExecutor,
worker_pool: Optional[Any] = None,
interval_minutes: int = 30,
):
self.executor = executor
self.worker_pool = worker_pool
self.interval_minutes = interval_minutes
self.running = False
self._stop_event = asyncio.Event()
@@ -50,7 +52,7 @@ class SchedulerService:
def validate_all_now(self) -> str:
"""立即执行一次全量验证,返回 Job ID"""
job_id = self.executor.submit_job(ValidateAllJob())
job_id = self.executor.submit_job(ValidateAllJob(validator_pool=self.worker_pool))
logger.info(f"ValidateAllJob submitted: {job_id}")
return job_id
@@ -58,7 +60,7 @@ class SchedulerService:
"""定时循环"""
while self.running:
try:
self.executor.submit_job(ValidateAllJob())
self.executor.submit_job(ValidateAllJob(validator_pool=self.worker_pool))
except Exception as e:
logger.error(f"Scheduler loop error: {e}", exc_info=True)
# 等待下一次