Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add 5-minute test of Celery.

  • Loading branch information...
commit 20d27c6948512f9c5452952af91c6e547213acbb 1 parent 1b9905f
@rduplain authored
Showing with 67 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +48 −0 README.rst
  3. +6 −0 celeryconfig.py
  4. +6 −0 tasks.py
View
7 .gitignore
@@ -0,0 +1,7 @@
+/build/
+/dist/
+.DS_Store
+*.egg
+*.egg-info
+*.py[co]
+.tox
View
48 README.rst
@@ -0,0 +1,48 @@
+========================================================
+ Simple Example of a Distributed Task Queue with Celery
+========================================================
+
+Get Started
+-----------
+
+Setup a broker as described in the Celery docs.
+Create a virtualenv and ``pip install celery``.
+
+Install RabbitMQ (and some utilities)::
+
+ sudo apt-get install rabbitmq-server amqp-tools
+
+By default, RabbitMQ provides a connection at::
+
+ amqp://guest:guest@localhost:5672//
+
+To configure RabbitMQ, see:
+http://www.rabbitmq.com/configure.html
+
+
+Run the Example
+---------------
+
+Starting with:
+http://docs.celeryq.org/en/latest/getting-started/first-steps-with-celery.html
+
+Make sure RabbitMQ is running, then have several terminal sessions handy.
+In one terminal session, run celeryd::
+
+ celeryd -E --loglevel=INFO # -E provides events for monitoring
+
+In another, monitor workers::
+
+ celeryev
+
+In another, running Python::
+
+ >>> from tasks import add
+ >>> add.delay(6, 36)
+ <AsyncResult: ...>
+ >>> result = _
+ >>> result.result
+ 42
+ >>>
+
+Look for details from celeryd logging and celeryev.
View
6 celeryconfig.py
@@ -0,0 +1,6 @@
+BROKER_URL = 'amqp://guest:guest@localhost:5672//'
+CELERY_IMPORTS = ('tasks', )
+
+CELERY_RESULT_BACKEND = 'amqp'
+CELERY_RESULT_PERSISTENT = True
+CELERY_TASK_RESULT_EXPIRES = None
View
6 tasks.py
@@ -0,0 +1,6 @@
+from celery.task import task
+
+
+@task
+def add(x, y):
+ return x + y
Please sign in to comment.
Something went wrong with that request. Please try again.