Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds sample tasks

  • Loading branch information...
commit b6c8514f0a4c193c656df3b367e5aa6896564029 1 parent 9f584f1
@mher authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 examples/tasks.py
View
31 examples/tasks.py
@@ -0,0 +1,31 @@
+import time
+
+from celery import Celery
+
+celery = Celery("tasks", broker="amqp://guest:guest@localhost:5672")
+celery.conf.CELERY_RESULT_BACKEND = "amqp"
+
+
+@celery.task
+def add(x, y):
+ return int(x) + int(y)
+
+
+@celery.task
+def sleep(seconds):
+ time.sleep(float(seconds))
+ return seconds
+
+
+@celery.task
+def echo(msg):
+ return msg
+
+
+@celery.task
+def error(msg):
+ raise Exception(msg)
+
+
+if __name__ == "__main__":
+ celery.start()
Please sign in to comment.
Something went wrong with that request. Please try again.