CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 7s
CI & Build / TypeScript typecheck (push) Successful in 12s
CI & Build / integration (push) Successful in 24s
CI & Build / Python tests (push) Successful in 55s
CI & Build / Build & push image (push) Successful in 24s
- background.start_periodic(interval, work, label=) replaces the three hand-rolled while-True/sleep/try loops in logging, auth and notifications. - services/scheduler.ScheduledJob replaces the four private BackgroundScheduler copies in recurrence/version_pinning/trash/db_maintenance schedulers; public start_/stop_/reschedule_ surfaces unchanged. - api_keys.hash_token is the one sha256 helper; auth.py used to inline it 5x. - auth.is_registration_open reads via settings.get_admin_setting; notification prefs read via settings.get_setting; _fire_share_email uses _get_user_email. - projects.get_project_summary / milestones.get_project_milestone_summary are now the one-id view of their batch siblings instead of a second copy of the queries; sharing.best_permission_by (was _deduplicate_by_permission) is the one rank-dedup, now also used by list_projects_for_user. - backup: the row builders for every section both exporters carry are named functions, so a column added to one export cannot silently miss the other. - iso() from models.base replaces the attr.isoformat()-if-attr-else-None idiom and db_maintenance._iso across services; backup keeps its explicit shape. - trash.py hoists the sql_delete/timedelta imports it re-imported per function. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Scheduler for recurring-task spawning.
|
|
|
|
Every 15 minutes, creates the next occurrence of any recurring task whose spawn
|
|
time has arrived — draining `recurrence_next_spawn_at`, which is armed on task
|
|
completion. Without this job, recurring tasks would never recur.
|
|
|
|
One ScheduledJob (services/scheduler.py), like the other *_scheduler modules.
|
|
(Formerly event_scheduler.py, which also ran event reminders + CalDAV sync;
|
|
those were removed when the calendar surface was retired.)
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import logging
|
|
|
|
from apscheduler.triggers.interval import IntervalTrigger
|
|
|
|
from scribe.services.scheduler import ScheduledJob
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def _run_recurrence_spawn() -> None:
|
|
from scribe.services.recurrence import spawn_recurring_tasks # noqa: PLC0415
|
|
await spawn_recurring_tasks()
|
|
|
|
|
|
_JOB = ScheduledJob("recurrence_spawn", _run_recurrence_spawn, label="Recurring-task spawn")
|
|
|
|
|
|
def start_recurrence_scheduler(loop: asyncio.AbstractEventLoop) -> None:
|
|
# Spawn the next occurrence of due recurring tasks every 15 minutes.
|
|
# Without this job, recurrence_next_spawn_at is armed on completion but
|
|
# never drained, so recurring tasks never recur.
|
|
_JOB.start(loop, IntervalTrigger(minutes=15), describe="recurring-task spawn every 15m")
|
|
|
|
|
|
def stop_recurrence_scheduler() -> None:
|
|
_JOB.stop()
|