every = models.IntegerField(
null=False,
verbose_name=_('Number of Periods'),
help_text=_('Number of interval periods to wait before '
'running the task again'),
validators=[MinValueValidator(1)],
)
period = models.CharField(
max_length=24, choices=PERIOD_CHOICES,
verbose_name=_('Interval Period'),
help_text=_('The type of period between task runs (Example: days)'),
)
every:区间数
period:间隔单位(days,hours, minutes, seconds, Microseconds)
name:任务简短说明
task:应该运行的celery任务的名称
interval:Interval任务运行的时间间隔
crontab:在Crontab计划上运行任务
solar:太阳升起时间表运行的任务
clocked:运行该任务的时钟时间表(只设置一种调度类型,其他类型保留为空)
args:SON编码的位置参数 (Example: [“arg1”, “arg2”])
kwargs:JSON编码的关键字参数
queue:队列定义在celery任务队列
exchange:覆盖交换低层AMQP路由
routing_key:
headers:
priority:
expires:
expire_seconds:不包含的imedelta与时间计划
one_off:如果为True,则调度将只运行任务一次
start_time:时间表应该开始的日期时间
enabled:设置为False则禁用调度
last_run_at:计划最后一次触发任务运行的日期时间。如果enabled设置为False,则重置为None
total_run_count:运行数进度表的次数
date_changed:此周期性任务最后一次修改的日期时间
description:对该周期任务的详细描述
name = models.CharField(
max_length=200, unique=True,
verbose_name=_('Name'),
help_text=_('Short Description For This Task'),
)
task = models.CharField(
max_length=200,
verbose_name='Task Name',
help_text=_('The Name of the Celery Task that Should be Run. '
'(Example: "proj.tasks.import_contacts")'),
)
# You can only set ONE of the following schedule FK's
# TODO: Redo this as a GenericForeignKey
interval = models.ForeignKey(
IntervalSchedule, on_delete=models.CASCADE,
null=True, blank=True, verbose_name=_('Interval Schedule'),
help_text=_('Interval Schedule to run the task on. '
'Set only one schedule type, leave the others null.'),
)
crontab = models.ForeignKey(
CrontabSchedule, on_delete=models.CASCADE, null=True, blank=True,
verbose_name=_('Crontab Schedule'),
help_text=_('Crontab Schedule to run the task on. '
'Set only one schedule type, leave the others null.'),
)
solar = models.ForeignKey(
SolarSchedule, on_delete=models.CASCADE, null=True, blank=True,
verbose_name=_('Solar Schedule'),
help_text=_('Solar Schedule to run the task on. '
'Set only one schedule type, leave the others null.'),
)
clocked = models.ForeignKey(
ClockedSchedule, on_delete=models.CASCADE, null=True, blank=True,
verbose_name=_('Clocked Schedule'),
help_text=_('Clocked Schedule to run the task on. '
'Set only one schedule type, leave the others null.'),
)
# TODO: use django's JsonField
args = models.TextField(
blank=True, default='[]',
verbose_name=_('Positional Arguments'),
help_text=_(
'JSON encoded positional arguments '
'(Example: ["arg1", "arg2"])'),
)
kwargs = models.TextField(
blank=True, default='{}',
verbose_name=_('Keyword Arguments'),
help_text=_(
'JSON encoded keyword arguments '
'(Example: {"argument": "value"})'),
)
queue = models.CharField(
max_length=200, blank=True, null=True, default=None,
verbose_name=_('Queue Override'),
help_text=_(
'Queue defined in CELERY_TASK_QUEUES. '
'Leave None for default queuing.'),
)
# you can use low-level AMQP routing options here,
# but you almost certaily want to leave these as None
# http://docs.celeryproject.org/en/latest/userguide/routing.html#exchanges-queues-and-routing-keys
exchange = models.CharField(
max_length=200, blank=True, null=True, default=None,
verbose_name=_('Exchange'),
help_text=_('Override Exchange for low-level AMQP routing'),
)
routing_key = models.CharField(
max_length=200, blank=True, null=True, default=None,
verbose_name=_('Routing Key'),
help_text=_('Override Routing Key for low-level AMQP routing'),
)
headers = models.TextField(
blank=True, default='{}',
verbose_name=_('AMQP Message Headers'),
help_text=_('JSON encoded message headers for the AMQP message.'),
)
priority = models.PositiveIntegerField(
default=None, validators=[MaxValueValidator(255)],
blank=True, null=True,
verbose_name=_('Priority'),
help_text=_(
'Priority Number between 0 and 255. '
'Supported by: RabbitMQ, Redis (priority reversed, 0 is highest).')
)
expires = models.DateTimeField(
blank=True, null=True,
verbose_name=_('Expires Datetime'),
help_text=_(
'Datetime after which the schedule will no longer '
'trigger the task to run'),
)
expire_seconds = models.PositiveIntegerField(
blank=True, null=True,
verbose_name=_('Expires timedelta with seconds'),
help_text=_(
'Timedelta with seconds which the schedule will no longer '
'trigger the task to run'),
)
one_off = models.BooleanField(
default=False,
verbose_name=_('One-off Task'),
help_text=_(
'If True, the schedule will only run the task a single time'),
)
start_time = models.DateTimeField(
blank=True, null=True,
verbose_name=_('Start Datetime'),
help_text=_(
'Datetime when the schedule should begin '
'triggering the task to run'),
)
enabled = models.BooleanField(
default=True,
verbose_name=_('Enabled'),
help_text=_('Set to False to disable the schedule'),
)
last_run_at = models.DateTimeField(
auto_now=False, auto_now_add=False,
editable=False, blank=True, null=True,
verbose_name=_('Last Run Datetime'),
help_text=_(
'Datetime that the schedule last triggered the task to run. '
'Reset to None if enabled is set to False.'),
)
total_run_count = models.PositiveIntegerField(
default=0, editable=False,
verbose_name=_('Total Run Count'),
help_text=_(
'Running count of how many times the schedule '
'has triggered the task'),
)
date_changed = models.DateTimeField(
auto_now=True,
verbose_name=_('Last Modified'),
help_text=_('Datetime that this PeriodicTask was last modified'),
)
description = models.TextField(
blank=True,
verbose_name=_('Description'),
help_text=_(
'Detailed description about the details of this Periodic Task'),
)