Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery not picking CELERY_ALWAYS_EAGER settings

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.

like image 911
AlexA Avatar asked May 12 '17 08:05

AlexA


People also ask

How do I manually run celery?

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.

What is Celery_always_eager?

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()).


1 Answers

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_.

like image 141
GDorn Avatar answered Sep 20 '22 10:09

GDorn