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.
You can use the . apply method of a task to ensure that it is run eagerly and locally. The result instance has the same API as the usual AsyncResult type, except that the result is always evaluated eagerly and locally and the . apply() method will block until the task is run to completion.
It means Celery will not schedule task to run like it would regularly do, via sending a message to the broker. Instead it will run it inside the process that is calling the task (via . apply_async() or . delay()).
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_.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With