Celery-Django: unable to complete tasks asynchronously

I am trying to perform some tasks in the background while users are browsing my site, but whenever I call a function using Celery, it runs synchronously, not asynchronously.

for example, when I call the .delay () function, the whole site freezes until the function.delay () function returns. Other methods of calling functions in a similar way (apply_async, subtasks) show the same problem.

I assume that something in Django or Celery is not configured correctly, but I do not 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] -------------- celery@iMac.local 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] celery@iMac.local has started. 
+4
source share
1 answer

Try to remove

 CELERY_ALWAYS_EAGER = True 

You are clearly asking celery to perform tasks synchronously. He will always wait for the result. This option is useful for writing unit tests, etc.

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

+8
source

All Articles