Django Celery Beat导入/ KeyError问题

时间:2014-04-29 21:10:43

标签: django celery

我正在使用带有Celery的Django 1.6。我有这项任务,我已按计划运行。一切看起来都正确,但是当Celery(节拍)运行时我得到了这个导入错误:

Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see http://bit.ly/gLye1c for more information.

The full contents of the message body was:
{'utc': True, 'chord': None, 'args': [], 'retries': 0, 'expires': None, 'task': 'bot_data.tasks.get_unanswered_threads', 'callbacks': None, 'errbacks': None, 'timelimit': (None, None), 'taskset': None, 'kwargs': {}, 'eta': None, 'id': '6143f259-721b-4984-99ae-790c00633271'} (233b)
Traceback (most recent call last):
  File "/home/one/.virtualenvs/bot/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 455, in on_task_received
    strategies[name](message, body,
KeyError: 'bot_data.tasks.get_unanswered_threads'

base.py:

from datetime import timedelta

CELERYBEAT_SCHEDULE = {
    'get-unanswered-threads--every-15-seconds': {
        'task': 'bot_data.tasks.get_unanswered_threads',
        'schedule': timedelta(seconds=15),
        'args': ()
    },
}
CELERY_TIMEZONE = 'UTC'

来自bot_data / get_unanswered_threads:

@task()
def get_unanswered_threads():
    slug = 'forums/threads/unanswered.json?PageSize=100'
    thread_batch = []

2 个答案:

答案 0 :(得分:0)

没关系,我的bot_data.tasks.get_unanswered_threads错误了。

答案 1 :(得分:0)

doc's将注释指定为@shared_task而不是@task