Index
scheduler
¶
Task scheduler module — cron/interval/once scheduling with SQLite persistence.
Classes¶
ScheduledTask
dataclass
¶
ScheduledTask(
id: str,
prompt: str,
schedule_type: str,
schedule_value: str,
context_mode: str = "isolated",
status: str = "active",
next_run: Optional[str] = None,
last_run: Optional[str] = None,
agent: str = "simple",
tools: str = "",
metadata: Dict[str, Any] = dict(),
)
A task scheduled for future or recurring execution.
Methods:¶
to_dict
¶
Serialize to a plain dict for store persistence.
Source code in src/diapason/scheduler/scheduler.py
from_dict
classmethod
¶
from_dict(d: Dict[str, Any]) -> ScheduledTask
Deserialize from a plain dict.
Source code in src/diapason/scheduler/scheduler.py
TaskScheduler
¶
TaskScheduler(
store: SchedulerStore,
system: Any = None,
*,
poll_interval: int = 60,
bus: Any = None,
)
Scheduler that polls for due tasks and executes them.
| PARAMETER | DESCRIPTION |
|---|---|
store
|
The persistence backend.
TYPE:
|
system
|
Optional
TYPE:
|
poll_interval
|
Seconds between poll cycles (default 60).
TYPE:
|
bus
|
Optional event bus for publishing scheduler events.
TYPE:
|
Source code in src/diapason/scheduler/scheduler.py
Methods:¶
start
¶
Start the background polling daemon thread.
Source code in src/diapason/scheduler/scheduler.py
stop
¶
Signal the background thread to stop and wait for it.
Source code in src/diapason/scheduler/scheduler.py
create_task
¶
create_task(
prompt: str,
schedule_type: str,
schedule_value: str,
**kwargs: Any,
) -> ScheduledTask
Create and persist a new scheduled task.
Source code in src/diapason/scheduler/scheduler.py
list_tasks
¶
list_tasks(
*, status: Optional[str] = None
) -> List[ScheduledTask]
Return tasks, optionally filtered by status.
Source code in src/diapason/scheduler/scheduler.py
pause_task
¶
Pause an active task.
Source code in src/diapason/scheduler/scheduler.py
resume_task
¶
Resume a paused task.
Source code in src/diapason/scheduler/scheduler.py
cancel_task
¶
Cancel a task (sets status to cancelled).
Source code in src/diapason/scheduler/scheduler.py
SchedulerStore
¶
SQLite CRUD store for scheduled tasks and their run logs.
Source code in src/diapason/scheduler/store.py
Methods:¶
save_task
¶
Insert or replace a scheduled task record.
Source code in src/diapason/scheduler/store.py
get_task
¶
Retrieve a single task by ID, or None if not found.
Source code in src/diapason/scheduler/store.py
list_tasks
¶
Return all tasks, optionally filtered by status.
Source code in src/diapason/scheduler/store.py
get_due_tasks
¶
Return active tasks whose next_run is at or before now_iso.
Source code in src/diapason/scheduler/store.py
update_task
¶
delete_task
¶
log_run
¶
log_run(
task_id: str,
started_at: str,
finished_at: str,
success: bool,
result: str = "",
error: str = "",
) -> None
Record a single execution of a task.
Source code in src/diapason/scheduler/store.py
get_run_logs
¶
Return the most recent run logs for task_id.