Tasks
The Task class is a model that represents a scheduled job to be executed by the system's scheduler. It is based on the apscheduler library.
Task Class
The Task defines a scheduled job.
Fields
name: A unique name for the task.func: The dotted path to the function to be executed.replace_existing: A boolean that, if true, will replace an existing task with the same name.max_instances: The maximum number of concurrent instances of this task.next_run_time: The scheduled time for the next run.args: A JSON list of positional arguments to pass to the function.kwargs: A JSON object of keyword arguments to pass to the function.trigger: The type of trigger. Currently, onlyintervalis supported via the model, butcronis used internally.trigger_config: A JSON object with the trigger-specific configuration.active: A boolean to enable or disable the task.
Triggers
IntervalTrigger
The IntervalTrigger is used to run a task at fixed intervals.
Accepted Fields:
weeks(int): number of weeks to waitdays(int): number of days to waithours(int): number of hours to waitminutes(int): number of minutes to waitseconds(int): number of seconds to waitstart_date(datetime|str): starting point for the interval calculationend_date(datetime|str): latest possible date/time to trigger ontimezone(datetime.tzinfo|str): time zone to use for the date/time calculationsjitter(int|None): advance or delay the job execution byjitterseconds at most.
CronTrigger
The CronTrigger is used to run a task at specific times, similar to the classic cron scheduler.
Accepted Fields:
year(int|str): 4-digit yearmonth(int|str): month (1-12)day(int|str): day of the (1-31)week(int|str): ISO week (1-53)day_of_week(int|str): number or name of weekday (0-6 or mon,tue,wed,thu,fri,sat,sun)hour(int|str): hour (0-23)minute(int|str): minute (0-59)second(int|str): second (0-59)start_date(datetime|str): earliest date/time to trigger on (inclusive)end_date(datetime|str): latest date/time to trigger on (inclusive)timezone(datetime.tzinfo|str): time zone to use for the date/time calculationsjitter(int|None): advance or delay the job execution byjitterseconds at most.