我正在尝试运行芹菜任务,但是正在接收KeyError
,我猜这是因为芹菜试图从chatbot.tasks.add获取我的tasks.py
文件。但是我很愚蠢,我将add((模块放在本地机器人/任务目录中。这是导致错误的原因。我以为我可以通过在python shell中进行from chatbot.tasks import add
来解决这个问题,但是我一直会收到一个" no模块"错误。
那么,我现在如何成功地将正确的密钥(chatbot.tasks.add(传递到外壳中的芹菜?
编辑:追溯错误:
[2018-02-13 04:32:47,609: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2018-02-13 04:32:47,628: INFO/MainProcess] mingle: searching for neighbors
[2018-02-13 04:32:48,641: INFO/MainProcess] mingle: all alone
[2018-02-13 04:32:48,674: WARNING/MainProcess] celery@Charles-PC ready.
[2018-02-13 04:33:52,023: ERROR/MainProcess] Received unregistered task of type 'bot.tasks.add'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see --- for more information.
The full contents of the message body was:
{'timelimit': (None, None), 'utc': True, 'chord': None, 'args': (2, 3), 'retries': 0, 'expires': None, 'task': 'bot.tasks.add
075-4bb0-89e5-b33a545c11f4'} (213b)
Traceback (most recent call last):
File "c:userselitebook.virtualenvschatbotlibsite-packagesceleryworkerconsumer.py", line 455, in on_task_received
strategies[name](message, body,
KeyError: 'bot.tasks.add'
我不知道您的应用程序布局,但是在我的芹菜项目(快3岁(中,我有两个文件: celeryConfig.py 和芹菜.py 。在 celery.py 中,我正在导入所有任务,因此我可以从导入项目的其他软件包中参考它们,或者当我想运行芹菜节拍任务时。