Skip to content

Commit 6405ebc

Browse files
alesoldaauvipy
authored andcommitted
Allow using non-true values in app kwargs
Trying to instantiate Celery app with non-true kwargs will not work for those configs which have True as default, for example, this will not have effect: >>> app = Celery(task_create_missing_queues=False) >>> app.conf['task_create_missing_queues'] True This fix simply changes the filtering which from now on will discard None values only. Fixes: celery#6865
1 parent b251235 commit 6405ebc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

celery/app/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def on_init(self):
323323
"""Optional callback called at init."""
324324

325325
def __autoset(self, key, value):
326-
if value:
326+
if value is not None:
327327
self._preconf[key] = value
328328
self._preconf_set_by_auto.add(key)
329329

t/unit/app/test_app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,11 @@ def test_with_broker(self, patching):
274274
with self.Celery(broker='foo://baribaz') as app:
275275
assert app.conf.broker_url == 'foo://baribaz'
276276

277-
def test_pending_confugration__kwargs(self):
277+
def test_pending_configuration_non_true__kwargs(self):
278+
with self.Celery(task_create_missing_queues=False) as app:
279+
assert app.conf.task_create_missing_queues is False
280+
281+
def test_pending_configuration__kwargs(self):
278282
with self.Celery(foo='bar') as app:
279283
assert app.conf.foo == 'bar'
280284

0 commit comments

Comments
 (0)