【发布时间】:2017-01-01 12:31:24
【问题描述】:
我已将 Celery 配置为在开发盒上为 Flask 应用程序运行异步作业,如下所示:
config.py:
class CeleryConfig(object):
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_CONFIG = CeleryConfig
manage.py:
celery_app = celery.Celery(config_source=app.config.get('CELERY_CONFIG'))
def run_celery():
appl = celery.current_app._get_current_object()
celery_worker = celery_worker.worker(app=appl)
options = {
'broker': config.get('CELERY_CONFIG').CELERY_BROKER_URL,
'traceback': True,
}
celery_worker.run(**options)
在启动应用程序之前我启动了redis:
./redis-server --daemonize yes
然后,当我运行应用程序 (run_celery) 时,会显示以下 Celery 配置:
- ** ---------- .> 运输:amqp://guest:**@localhost:5672//
- ** ---------- .> 结果:redis://localhost:6379/0
以及以下反复出现的错误:
错误/MainProcess 消费者:无法连接到 amqp://guest:**@127.0.0.1:5672//:[Errno 111] 连接被拒绝。
我不确定传输层为什么使用 RabbitMQ 以及为什么我无法启动 Celery。
【问题讨论】:
标签: python flask redis rabbitmq celery