小编yug*_*tar的帖子

在Python中设置celery任务后端的麻烦

我按照[ http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html ]中给出的所有步骤进行了操作.这是代码:

from __future__ import absolute_import
from celery import Celery

#app = Celery('tasks', broker='pyamqp://guest@localhost//')
app = Celery('tasks', backend='redis://localhost', broker='pyamqp://guest@localhost//')
@app.task
def add(x, y):
   return x + y
Run Code Online (Sandbox Code Playgroud)

当我使用以下命令运行芹菜工作者时

celery -A tasks worker --loglevel=info
Run Code Online (Sandbox Code Playgroud)

设置后端时出现语法错误.这是错误消息:

[2018-07-10 16:37:21,970: CRITICAL/MainProcess] Unrecoverable error: SyntaxError('invalid syntax', ('c:\\users\\user_\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\celery\\backends\\redis.py', 22, 19, 'from . import async, base\n'))Traceback (most recent call last):  File "c:\users\user_\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\objects.py", line 42, in __get__    return obj.__dict__[self.__name__] KeyError: 'backend' During handling of the above exception, another exception occurred: Traceback (most recent call last):  File "c:\users\user_\appdata\local\programs\python\python37-32\lib\site-packages\celery\worker\worker.py", …
Run Code Online (Sandbox Code Playgroud)

python redis celery python-3.x redis-server

9
推荐指数
1
解决办法
4313
查看次数

标签 统计

celery ×1

python ×1

python-3.x ×1

redis ×1

redis-server ×1