Skip to content
Browse files

Document celery.

  • Loading branch information...
1 parent 1b3c8c1 commit f2509e7e7e57f98cd7859ee02e3879f37bbf952f @davedash davedash committed Nov 22, 2011
Showing with 64 additions and 1 deletion.
  1. +2 −1 conf.py
  2. +62 −0 userguide/celery.rst
View
3 conf.py
@@ -220,6 +220,7 @@
intersphinx_mapping = dict(
python= ('http://docs.python.org/', None),
- django= ('https://docs.djangoproject.com/en/dev/', 'django.inv')
+ django= ('https://docs.djangoproject.com/en/dev/', 'django.inv'),
+ celery= ('http://celery.readthedocs.org/en/latest/', None)
)
View
62 userguide/celery.rst
@@ -0,0 +1,62 @@
+===========================
+Asynchronous Tasks (Celery)
+===========================
+
+
+One goal in developing web projects is to minimize request times.
+Long request times lead to users leaving your website and ultimately
+a loss of revenue and mindshare.
+Smaller request times lead to huger bags of money that you can take to the
+bank.
+
+If you can separate things that need to happen immediately
+(e.g. sending a message, setting a privacy setting) versus things that can
+take some time (e.g. deleting a tag, updating a search index,
+hitting an external API)
+you can take advantage of a queue.
+
+Playdoh includes Celery for managing asynchronous task queues.
+Celery is one of the more popular task queue systems for Django.
+
+In production Celery uses RabbitMQ (or some other backend) to store tasks
+that you want to do later.
+
+While developing locally, Playdoh defaults to::
+
+ CELERY_ALWAYS_EAGER = True
+
+This causes your Celery tasks to happen during the request-response cycle,
+which is great for development.
+
+You can place your tasks in ``tasks.py`` and decorate them like so::
+
+ from celery.task import task
+
+
+ @task
+ def my_awesome_task():
+ time.sleep(100000)
+
+You can get more advanced with the decorator so `read the docs`__.
+
+__ http://readthedocs.org/docs/django-celery/
+
+In your code (often in a view or in the model) you can call the task by doing::
+
+ my_awesome_task.delay(arg1, arg2, kwarg1="x", kwarg2="y")
+
+
+``task.apply_async`` can also be used, but has a more complicated syntax.
+See :ref:`Executing Tasks<celery:guide-executing>`.
+
+.. seealso::
+
+ * `Celery Docs`__
+ * `Django Celery Docs`__
+ * `Queue everything and delight everyone`__
+ * `Example settings/local.py`__
+
+__ http://readthedocs.org/docs/celery/
+__ http://readthedocs.org/docs/django-celery/
+__ http://decafbad.com/blog/2008/07/04/queue-everything-and-delight-everyone
+__ https://github.com/mozilla/affiliates/blob/master/settings/local.py-dist

0 comments on commit f2509e7

Please sign in to comment.
Something went wrong with that request. Please try again.