Added examples/eventlet
This commit is contained in:
Родитель
85d1b19a2a
Коммит
3eeafdb1cc
|
@ -0,0 +1,15 @@
|
|||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.getcwd())
|
||||
|
||||
CELERYD_POOL = "eventlet"
|
||||
|
||||
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,14 @@
|
|||
from celery.decorators import task
|
||||
from eventlet.green import urllib2
|
||||
|
||||
|
||||
@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
|
Загрузка…
Ссылка в новой задаче