4

I'm trying to run some tasks in the background while users browse my site, but whenever I call a function using Celery it seems to be executed synchronously instead of asynchronously.

e.g., when I call function.delay() the entire site hangs until function.delay() returns. Other methods of calling functions in a similar manner (apply_async, subtasks) exhibit the same problem.

I'm guessing something in either Django or Celery is misconfigured, but I don't know what it is.

Celery configuration in settings.py:

import djcelery
djcelery.setup_loader()

CELERY_RESULT_BACKEND = "amqp"
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "test"
BROKER_PASSWORD = "test"
BROKER_VHOST = "testhost"

TEST_RUNNER = "djcelery.contrib.test_runner.run_tests"

CELERY_IMPORTS = ("myapp.tasks",)

BROKER_BACKEND = "memory"
CELERY_ALWAYS_EAGER = True

Trying to start the Celery daemon with "./manage.py celeryd", I get the following output:

[2011-09-23 09:25:38,026: WARNING/MainProcess]  

 -------------- [email protected] v2.2.7
---- **** -----
--- * ***  * -- [Configuration]
-- * - **** ---   . broker:      memory://test@localhost:5672/testhost
- ** ----------   . loader:      djcelery.loaders.DjangoLoader
- ** ----------   . logfile:     [stderr]@WARNING
- ** ----------   . concurrency: 4
- ** ----------   . events:      OFF
- *** --- * ---   . beat:        OFF
-- ******* ----
--- ***** ----- [Queues]
 --------------   . celery:      exchange:celery (direct) binding:celery


[2011-09-23 09:25:38,035: WARNING/MainProcess] [email protected] has started.
4
  • What web server are you using? Commented Sep 22, 2011 at 11:31
  • I'm currently running off localhost with the default Django setup. Planning on using Apache once I get things off the ground. Commented Sep 22, 2011 at 15:46
  • Hmm, provide your celery related configuration then and describe to us how do you start celery deamon. Commented Sep 23, 2011 at 6:40
  • I'm not entirely sure what a lot of these configuration settings do. This project was sort of dumped in my lap in a semi-working state a few weeks back (and I had no experience with Django, Celery, or even Python beforehand). I'm only now starting to find some things that aren't quite working right. Commented Sep 23, 2011 at 13:52

1 Answer 1

8

Try removing

CELERY_ALWAYS_EAGER = True

You are explicitly asking celery to execute tasks synchronously. It'll always wait for the result. This setting is useful for writing unit tests etc.

Read http://ask.github.com/celery/configuration.html

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

Comments

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.