python - django - 安排重复任务间隔

标签 python django scheduled-tasks

我使用 django_rq 和 rq_scheduler 来执行一些重复性作业(例如 cron)

默认间隔似乎是 60 秒,但我想将其更改为 600。

#tasks.py 
from rq import get_current_job
from django_rq import job

@job('default',timeout=-1)
def updateCheck():
    print "something"

(向装饰器添加 'interval=600' 不起作用)

设置间隔的正确方法是什么?

最佳答案

您正在使用

from django_rq import job

查看源代码here 。您可以看到 job 方法最终调用了 rq.decorators 的 job 方法。如果你更深入地了解source code ,您可以看到没有接受任何 interval 参数。

https://github.com/ui/rq-scheduler/确实提供调度间隔 scheduler.schedule()

关于python - django - 安排重复任务间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32026684/

相关文章:

python - Matplotlib 设置子图的面颜色

变量中的 Python 字符串方法

python - Django 模板检查当前时间是否介于开始时间和结束时间之间

django - 更新相关模型中的 auto_now DateTimeField

java - 如何停止Executors.newSingleThreadScheduledExecutor

python - cv2.VideoCapture.read() 不工作

python - 移动数据帧的每个值而不更改列

python - 属性错误 : module 'django.db.models' has no attribute 'RegexField' . python (django)

java - Spring,Java - 并行运行许多计划任务,每个任务都有一个实例

java - 使用 ScheduledExecutorService 安排每月任务