The Python Oracle

Is there any way to change the Celery config programmatically, after app init?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Over Ancient Waters Looping

--

Chapters
00:00 Is There Any Way To Change The Celery Config Programmatically, After App Init?
01:23 Accepted Answer Score 7
01:44 Thank you

--

Full question
https://stackoverflow.com/questions/3636...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #unittesting #testing #configuration #celery

#avk47



ACCEPTED ANSWER

Score 7


Simply changing variables on Celery's .conf object (an instance of Settings) works:

app.conf.CELERY_ALWAYS_EAGER = True

Although conf is indeed a @cached_property of Celery (in version 3.1.22 anyway), this caches the instance returned, not all the values - so the configuration is indeed dynamically updatable.