我需要在我的django项目中运行长时间的任务。希望将redis作为经纪人使用芹菜。安装Redis的运行:django项目中的芹菜异步任务。怎么运行的?
的服务器已经准备好接受端口6379
连接比我安装Django,芹菜,配置:
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] [email protected] 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)
它等待很长,呈现回溯http://dpaste.com/555939/。它可能是什么?也许我想念什么?
问题是,我跑壳为: >蟒蛇manage.py壳 – greg
嗯,是的,你只能在你的Django应用程序运行文件中的芹菜的确,应该已经注意到了:) – fijter