Browse Source

Added examples/gevent

Ask Solem 14 years ago
parent
commit
f74558eaff
2 changed files with 30 additions and 0 deletions
  1. 15 0
      examples/gevent/celeryconfig.py
  2. 15 0
      examples/gevent/tasks.py

+ 15 - 0
examples/gevent/celeryconfig.py

@@ -0,0 +1,15 @@
+import os
+import sys
+sys.path.insert(0, os.getcwd())
+
+CELERYD_POOL = "gevent"
+
+BROKER_HOST = "localhost"
+BROKER_USER = "guest"
+BROKER_PASSWORD = "guest"
+BROKER_VHOST = "/"
+CELERY_DISABLE_RATE_LIMITS = True
+CELERY_RESULT_BACKEND = "amqp"
+CELERY_TASK_RESULT_EXPIRES = 30 * 60
+
+CELERY_IMPORTS = ("tasks", )

+ 15 - 0
examples/gevent/tasks.py

@@ -0,0 +1,15 @@
+import urllib2
+
+from celery.decorators import task
+
+
+@task(ignore_result=True)
+def urlopen(url):
+    print("Opening: %r" % (url, ))
+    try:
+        body = urllib2.urlopen(url).read()
+    except Exception, exc:
+        print("Exception for %r: %r" % (url, exc, ))
+        return url, 0
+    print("Done with: %r" % (url, ))
+    return url, 1