Added examples/gevent
This commit is contained in:
Родитель
bbd8127581
Коммит
f74558eaff
|
@ -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", )
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче