Django项目中的Celery异步任务。怎么运行的?
|
我需要在django项目中运行长任务。愿意将芹菜和Redis用作经纪人。已安装的redis运行:
服务器现在准备接受端口6379上的连接
比我安装django-celery,配置:
import djcelery
djcelery.setup_loader()
BROKER_HOST = \"localhost\"
BROKER_PORT = 6379 #redis
BROKER_USER = \"guest\"
BROKER_PASSWORD = \"guest\"
BROKER_VHOST = \"/\"
并运行它:
python manage.py celeryd -l DEBUG
[...]
[2011-06-18 10:31:37,913: DEBUG/MainProcess] Starting thread Timer...
[2011-06-18 10:31:37,914: DEBUG/MainProcess] Starting thread Consumer...
[2011-06-18 10:31:37,914: WARNING/MainProcess] celery@greg... has started.
[2011-06-18 10:31:37,914: DEBUG/MainProcess] Consumer: Re-establishing connection to the broker...
我的示例任务如下所示:
from celery.decorators import task
@task()
def add(x, y):
return x + y
现在我尝试在shell中运行它:
In [3]: from message.tasks import add
In [4]: r=add.delay(2, 5)
它会等待很长时间,然后呈现Traceback http://dpaste.com/555939/。可以是什么?也许我想念什么?
没有找到相关结果
已邀请:
2 个回复
填盖
设置丢失。这是使用Redis的示例配置:
屠创氓读叔