From 243d475b199f13ac2aa85d4225abd3a094ae781f Mon Sep 17 00:00:00 2001 From: Bas ten Berge Date: Mon, 5 Oct 2020 07:09:29 +0200 Subject: [PATCH] Contains a workaround for the capitalized configuration issue (#6385) * Contains a workaround for the capitalized configuration issue * Update celery/apps/worker.py Co-authored-by: Omer Katz * Update celery/apps/worker.py Co-authored-by: Omer Katz Co-authored-by: Omer Katz --- celery/apps/worker.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/celery/apps/worker.py b/celery/apps/worker.py index 6c1b5eb1c2..2a9df0c2e7 100644 --- a/celery/apps/worker.py +++ b/celery/apps/worker.py @@ -141,12 +141,25 @@ def on_start(self): app.log.redirect_stdouts(self.redirect_stdouts_level) # TODO: Remove the following code in Celery 6.0 - if app.conf.maybe_warn_deprecated_settings(): - logger.warning( - "Please run `celery upgrade settings path/to/settings.py` " - "to avoid these warnings and to allow a smoother upgrade " - "to Celery 6.0." - ) + # This qualifies as a hack for issue #6366. + # a hack via app.__reduce_keys__(), but that may not work properly in + # all cases + warn_deprecated = True + config_source = app._config_source + if isinstance(config_source, str): + # Don't raise the warning when the settings originate from + # django.conf:settings + warn_deprecated = config_source.lower() not in [ + 'django.conf:settings', + ] + + if warn_deprecated: + if app.conf.maybe_warn_deprecated_settings(): + logger.warning( + "Please run `celery upgrade settings path/to/settings.py` " + "to avoid these warnings and to allow a smoother upgrade " + "to Celery 6.0." + ) def emit_banner(self): # Dump configuration to screen so we have some basic information