Skip to content

Index

diapason.scheduler

Task scheduler module — cron/interval/once scheduling with SQLite persistence.

ScheduledTask dataclass

A task scheduled for future or recurring execution.

from_dict(d) classmethod

Deserialize from a plain dict.

to_dict()

Serialize to a plain dict for store persistence.

SchedulerStore

SQLite CRUD store for scheduled tasks and their run logs.

close()

Close the underlying SQLite connection.

delete_task(task_id)

Delete a task by ID.

get_due_tasks(now_iso)

Return active tasks whose next_run is at or before now_iso.

get_run_logs(task_id, limit=10)

Return the most recent run logs for task_id.

get_task(task_id)

Retrieve a single task by ID, or None if not found.

list_tasks(status=None)

Return all tasks, optionally filtered by status.

log_run(task_id, started_at, finished_at, success, result='', error='')

Record a single execution of a task.

save_task(task)

Insert or replace a scheduled task record.

update_task(task)

Update an existing task (same as save_task — uses INSERT OR REPLACE).

TaskScheduler

Scheduler that polls for due tasks and executes them.

Parameters

store: The persistence backend. system: Optional DiapasonSystem instance for executing prompts. poll_interval: Seconds between poll cycles (default 60). bus: Optional event bus for publishing scheduler events.

cancel_task(task_id)

Cancel a task (sets status to cancelled).

create_task(prompt, schedule_type, schedule_value, **kwargs)

Create and persist a new scheduled task.

list_tasks(*, status=None)

Return tasks, optionally filtered by status.

pause_task(task_id)

Pause an active task.

resume_task(task_id)

Resume a paused task.

start()

Start the background polling daemon thread.

stop()

Signal the background thread to stop and wait for it.