29

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
  • 2
    have you placed from .celery import app as celery_app in your proj/proj/__init__.py? Commented May 12, 2017 at 9:03

2 Answers 2

67

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

Sign up to request clarification or add additional context in comments.

Comments

-1

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

4 Comments

I am event not running a worker, I have Django runserver running (also, restarted) and expecting celery tasks to execute inside it.
Sorry, I did not get your point. How you are managing celery to up and running? are you managing it through supervisor? Did you run this command celery worker -A yourapp --loglevel=INFO to start celery or something else
I managed to run celery worker -A yourapp --loglevel=INFO successfully and it's receieving tasks. Now I have a different goal: to help other developers run Django and tasks without celery, so that tasks are immediately executed inside Django process. For instance, this helps debugging tasks.
Can confirm with CELERY_TASK_ALWAYS_EAGER = True in settings will run the tasks synchronously (so in multi-setting environments changing testing and local environments) one doesn't need to start up celery. This is helpful for team members who don't know celery and reduces overhead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.