Invert blocklist scheduler dependency to task callback

This commit is contained in:
2026-04-15 21:31:08 +02:00
parent a5e95e2061
commit 73cc212e28
6 changed files with 25 additions and 4 deletions

View File

@@ -525,9 +525,9 @@ def schedule_blocklist_job(
settings: Settings,
http_session: aiohttp.ClientSession,
config: ScheduleConfig,
run_import_callback: Callable[[Settings, aiohttp.ClientSession], Awaitable[None]],
) -> None:
"""Register or replace the scheduled blocklist import job."""
from app.tasks import blocklist_import as blocklist_import_task
if scheduler.get_job(JOB_ID):
scheduler.remove_job(JOB_ID)
@@ -555,7 +555,7 @@ def schedule_blocklist_job(
}
scheduler.add_job(
blocklist_import_task._run_import_with_resources,
run_import_callback,
trigger=trigger_type,
id=JOB_ID,
kwargs=kwargs,
@@ -654,10 +654,17 @@ async def update_schedule(
http_session: aiohttp.ClientSession,
settings: Settings,
config: ScheduleConfig,
run_import_callback: Callable[[Settings, aiohttp.ClientSession], Awaitable[None]],
) -> ScheduleInfo:
"""Persist a new schedule config and re-register the scheduled job."""
await set_schedule(db, config)
schedule_blocklist_job(scheduler, settings, http_session, config)
schedule_blocklist_job(
scheduler,
settings,
http_session,
config,
run_import_callback,
)
return await get_schedule_info(db, _get_job_next_run_at(scheduler))