我已經閱讀了不少類似於此的帖子,但沒有一篇似乎對我有意義。芹菜「收到未註冊任務的類型」
我想配置芹菜PeriodicTask以每5秒閃光,但是我就要掛了一個芹菜配置問題(我認爲)
通信/ tasks.py
import datetime
from celery.decorators import periodic_task
@periodic_task
def send_queued_messages():
# do something...
的myapp/settings.py
...
from comm.tasks import send_queued_messages
from datetime import timedelta
CELERYBEAT_SCHEDULE = {
'send_queued_messages_every_5_seconds': {
'task': 'comm.tasks.send_queued_messages', # Is the issue here? I've tried a dozen variations!!
'schedule': timedelta(seconds=5),
},
}
從我的錯誤日誌中的相關輸出:
23:41:00 worker.1 | [2015-06-10 03:41:00,657: ERROR/MainProcess] Received unregistered task of type 'send_queued_messages'.
23:41:00 worker.1 | The message has been ignored and discarded.
23:41:00 worker.1 |
23:41:00 worker.1 | Did you remember to import the module containing this task?
23:41:00 worker.1 | Or maybe you are using relative imports?
23:41:00 worker.1 | Please see http://bit.ly/gLye1c for more information.
23:41:00 worker.1 |
23:41:00 worker.1 | The full contents of the message body was:
23:41:00 worker.1 | {'utc': True, 'chord': None, 'args': [], 'retries': 0, 'expires': None, 'task': 'send_queued_messages', 'callbacks': None, 'errbacks': None, 'timelimit': (None, None), 'taskset': None, 'kwargs': {}, 'eta': None, 'id': 'a8ca18...227a56'} (216b)
消息正文顯示調用的任務是'send_queued_messages' - 然而'CELERYBEAT_SCHEDULE'具有'comm.tasks.send_queued_messages' - 參見[命名]上的文檔(http://celery.readthedocs.org/en/latest /userguide/tasks.html#names) – scytale
當我將CELERYBEAT_SCHEDULE更改爲send_queued_messages時,它仍然不起作用,我收到相同的錯誤消息。 –
嘗試運行'芹菜檢查註冊'看看你的任務是否正確註冊 – scytale