Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery and Flask - Cannot mix new setting names with old setting names

I have used this tutorial to set up Celery on my Flask application but i keep getting the following error:

File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\celery\app\base.py", line 141, in data
    return self.callback()
celery.exceptions.ImproperlyConfigured:

Cannot mix new setting names with old setting names, please
rename the following settings to use the old format:

include                              -> CELERY_INCLUDE

Or change all of the settings to use the new format :)

What am i doing wrong? The code i used is basically the same of the tutorial:

init.py

app = Flask(__name__)
app.config.from_object(Config)
app.config['TESTING'] = True
db = SQLAlchemy(app)
migrate = Migrate(app, db)

def make_celery(app):
    celery = Celery(
        app.import_name,
        backend=app.config['CELERY_RESULT_BACKEND'],
        broker=app.config['CELERY_BROKER_URL']
    )
    celery.conf.update(app.config)

    class ContextTask(celery.Task):
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return self.run(*args, **kwargs)

    celery.Task = ContextTask
    return celery


app.config.update(
    CELERY_BROKER_URL='redis://localhost:6379',
    CELERY_RESULT_BACKEND='redis://localhost:6379'
)
celery = make_celery(app)
like image 659
JayK23 Avatar asked Oct 22 '25 10:10

JayK23


1 Answers

the code you are using used old variable names
change lines
app.config.update(
CELERY_BROKER_URL='redis://localhost:6379',
CELERY_RESULT_BACKEND='redis://localhost:6379'
)
to
app.config.update(
broker_url='redis://localhost:6379',
result_backend='redis://localhost:6379'
)

like image 182
Siddharth Nobell Avatar answered Oct 25 '25 00:10

Siddharth Nobell