Don Smythe
Don Smythe

Reputation: 9814

Celery configuration for Flask application

I have configured Celery to run async jobs for a Flask application on a dev box like this:

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)

prior to starting the application I start redis:

./redis-server --daemonize yes

Then when I run the application (run_celery) I get the following Celery config displayed:

and the following recurring error:

ERROR/MainProcess consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.

I am not sure why the transport layer is using RabbitMQ and why I can't get Celery started.

Upvotes: 2

Views: 3737

Answers (1)

AArias
AArias

Reputation: 2568

It's because the parameter is BROKER_URL, not CELERY_BROKER_URL. Here's a complete list of possible settings: http://docs.celeryproject.org/en/latest/userguide/configuration.html#new-lowercase-settings

Note: that table is a conversion table for the new lower case settings in Celery 4.0, but as stated there: "Celery will still be able to read old configuration files, so there’s no rush in moving to the new settings format"

Upvotes: 2

Related Questions