Celery增加配置得三种方式:(redis为例)
from celery import Celery
# 增加配置,redis为例
# 第一种
app = Celery('demo',
backend='redis://:127.0.0.1:6379/2',
broker='redis://:127.0.0.1:6379/1')
# 第二种
app = Celery('demo')
app.conf.update(
broker_url='redis://:127.0.0.1:6379/1',
result_backend='redis://:127.0.0.1:6379/2',
)
# 第三种,导入.py模块,config中指定broker_url/result_backend
app = Celery('demo')
app.config_from_object('config')
如果redis有密码:
backend='redis://:redisredis@127.0.0.1:6379/2')
网友评论