|
@@ -128,6 +128,24 @@ def configure_app(app, config):
|
|
|
# them on the config object
|
|
|
app_config_from_env(app, prefix="FLASKBB_")
|
|
|
|
|
|
+ # Migrate Celery 4.x config to Celery 6.x
|
|
|
+ old_celery_config = app.config.get_namespace('CELERY_')
|
|
|
+ celery_config = {}
|
|
|
+ for key, value in old_celery_config.items():
|
|
|
+ config_key = f"CELERY_{key.upper()}"
|
|
|
+ # config is the new format
|
|
|
+ if key != "config":
|
|
|
+ celery_config[key] = value
|
|
|
+ try:
|
|
|
+ del app.config[config_key]
|
|
|
+ except KeyError:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # merge the new config with the old one
|
|
|
+ new_celery_config = app.config.get("CELERY_CONFIG")
|
|
|
+ new_celery_config.update(celery_config)
|
|
|
+ app.config.update({"CELERY_CONFIG": new_celery_config})
|
|
|
+
|
|
|
# Setting up logging as early as possible
|
|
|
configure_logging(app)
|
|
|
|
|
@@ -168,8 +186,7 @@ def configure_app(app, config):
|
|
|
|
|
|
def configure_celery_app(app, celery):
|
|
|
"""Configures the celery app."""
|
|
|
- app.config.update({"BROKER_URL": app.config["CELERY_BROKER_URL"]})
|
|
|
- celery.conf.update(app.config)
|
|
|
+ celery.conf.update(app.config.get("CELERY_CONFIG"))
|
|
|
|
|
|
TaskBase = celery.Task
|
|
|
|