Celery not picking CELERY_ALWAYS_EAGER settings

你。 提交于 2019-12-01 14:35:59

问题


I am running Django 1.8 + Celery 4.0.2 Celery is configured well and can run my Django tasks locally on redis backend. But when I try to use CELERY_ALWAYS_EAGER = True settings, this settings has no effect. Which is not the case with other settings, e.g. CELERY_TIMEZONE

Specifically, in pdb I see that app.conf.task_always_eager is False

lib/python2.7/site-packages/celery/app/task.py(520)apply_async() So somehow CELERY_ALWAYS_EAGER is not picked up and has no effect on app.conf.task_always_eager

More info from pdb:

> app.conf.get('CELERY_ALWAYS_EAGER')
> True
> app.conf.task_always_eager
> False

What can cause this? I know that Celery 4.x is in transition from old setting names to new ones, but they still promise old settings names still would be used as well.


回答1:


CELERY_ALWAYS_EAGER has been renamed to CELERY_TASK_ALWAYS_EAGER in version 4.0+.

More accurately, all-caps settings have been deprecated in favor of directly configuring the celery app object, and several have been namespaced to either use task_ or worker_ as a prefix. Because there's still backwards-compatability with all-caps settings, this indirectly renamed the all-caps setting as well.

From the changelog:

The celery_ prefix has also been removed, and task related settings from this name-space is now prefixed by task_, worker related settings with worker_.




回答2:


Please restart celery worker after setting CELERY_ALWAYS_EAGER = True in settings.py and see if it helps.



来源:https://stackoverflow.com/questions/43933022/celery-not-picking-celery-always-eager-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!