首页 文章

适用于Flask应用的芹菜配置

提问于
浏览
1

我已经配置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配置:

  • ** ---------- . > transport:amqp:// guest:** @ localhost:5672 //

  • ** ---------- . > results:redis:// localhost:6379/0

以及反复出现的错误:

ERROR / MainProcess使用者:无法连接到amqp:// guest:** @ 127.0.0.1:5672 //:[Errno 111]连接被拒绝 .

我不确定为什么传输层使用RabbitMQ以及为什么我不能开始使用芹菜 .

1 回答

相关问题