【问题标题】:Celery. Why my task work ONLY if I run this manualy in shell(manage.py shell)?芹菜。为什么我的任务只有在我在 shell(manage.py shell)中手动运行时才有效?
【发布时间】:2013-05-01 16:10:46
【问题描述】:
>>> from app.tasks import SendSomething
>>> eager_result = SendSomething().apply()

为什么我的任务只有在我在 shell(manage.py shell) 中手动运行时才有效?

settings.py

from datetime import timedelta
CELERYBEAT_SCHEDULE = {'send-something':
                       {'task': 'app.tasks.SendSomething',
                        'schedule': timedelta(seconds=300),
                        }}

我跑:

python manage.py celeryd

我有:

[Tasks]
  . app.tasks.SendSomething
[2013-05-01 18:44:22,895: WARNING/MainProcess] celery@aaa ready.

但不工作。

【问题讨论】:

    标签: django django-celery


    【解决方案1】:

    celeryd 是工作进程。默认情况下,它不安排定期任务。您可以使用-B 选项运行以与工作人员一起运行节拍进程

    python manage.py celeryd -B

    或者您可以运行额外的celerybeat 进程

    python manage.py celerybeat

    http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html#starting-the-scheduler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-03
      • 2013-06-26
      • 2016-07-09
      • 2013-10-04
      • 2019-07-26
      • 2011-10-29
      • 2021-02-21
      • 2021-10-18
      相关资源
      最近更新 更多