veritas.cron
Package Contents
Classes
Class to manage the scheduling of tasks |
Functions
|
decorator to schedule a function |
- class veritas.cron.Scheduler(database: dict = None)
Bases:
objectClass to manage the scheduling of tasks
- Parameters:
database (dict) – database configuration
- register_task(filename: str, module: str, function: callable, schedule: str, args: str) bool
register task
- Parameters:
filename (str) – filename of the task
module (str) – module of the task
function (callable) – function of the task
schedule (str) – schedule of the task
args (str) – arguments of the task
- Returns:
resposne – true if the task was registered
- Return type:
bool
- reschedule_task(id: str, schedule: str) bool
reschedule task
- Parameters:
id (str) – if of the task
schedule (str) – new schedule of the task
- Returns:
resposne – true if the task was rescheduled
- Return type:
bool
- deregister_task(id: str) bool
deregister task
- Parameters:
id (str) – id of the task
- Returns:
response – true if the task was deregistered
- Return type:
bool
- deregister_all_tasks() bool
deregister all tasks
- Returns:
resposne – true if all tasks were deregistered
- Return type:
bool
- get_all_tasks() list
get all tasks
- Returns:
tasks – list of all tasks
- Return type:
list
- get_all_runs() list
get all runs
- Returns:
runs – list of all runs
- Return type:
list
- get_failed_runs() list
get failed runs
- Returns:
runs – list of all failed runs
- Return type:
list
- get_task_by_filename(filename: str) list
get task by filename
- Parameters:
filename (str) – filename of the task
- Returns:
task – list of task
- Return type:
list
- add_run(job_id: str, started: str, started_int: int, finished: str, finished_int: int, result: str, error: str) bool
add run to database
- Parameters:
job_id (str) – job id
started (str) – when the job started
started_int (int) – when the job started as int
finished (str) – when the job finished
finished_int (int) – when the job finished as int
result (str) – result of the job
error (str) – error of the job
- Returns:
true if the run was added
- Return type:
response _ bool
- _open_database(database: dict = None) None
open database connection
- Parameters:
database (dict, optional) – database configuration, by default None
- _return_list_of_dicts(select_query: str) list
helper function to execute query and return a list of dicts
- Parameters:
select_query (str) – query to execute
- Returns:
resposne – list of dicts
- Return type:
list
- veritas.cron.schedule(schedule: str, args: list = None, run: bool = False)
decorator to schedule a function
- Parameters:
schedule (str) – when to run the function
args (list, optional) – arguments of the method, by default None
run (bool, optional) – should the task be run instead of schedule, by default False