Django芹菜定制周期性任务没有执行

时间:2013-05-09 19:06:43

标签: python django celery djcelery

我尝试using this code尝试动态添加/删除计划任务。

我的tasks.py文件如下所示:

from celery.decorators import task
import logging
log = logging.getLogger(__name__)

@task
def mytask():
    log.debug("Executing task")
    return

问题是任务实际上没有执行(即没有日志输出),但是我在celery日志文件中得到了以下消息,完全符合计划:

[2013-05-10 04:53:00,005: INFO/MainProcess] Got task from broker:   cron.tasks.mytask[dfcf397b-e30b-45bd-9f5f-11a17a51b6c4]
[2013-05-10 04:54:00,007: INFO/MainProcess] Got task from broker: cron.tasks.mytask[f013b3cd-6a0f-4060-8bcc-3bb51ffaf092]
[2013-05-10 04:55:00,007: INFO/MainProcess] Got task from broker: cron.tasks.mytask[dfc0d563-ff4b-4132-955a-4293dd3a9ac7]
[2013-05-10 04:56:00,012: INFO/MainProcess] Got task from broker: cron.tasks.mytask[ba093535-0d70-4dc5-89e4-441b72cfb61f]

我可以肯定地确认记录器配置正确且工作正常。如果我尝试在交互式shell中调用result = mytask.delay()result.state将无限期地包含状态PENDING

编辑:另见Django Celery Periodic Tasks Run But RabbitMQ Queues Aren't Consumed

0 个答案:

没有答案