Created
June 29, 2012 18:22
-
-
Save rustyrazorblade/3019787 to your computer and use it in GitHub Desktop.
celery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@rabbit:~# ls | |
build celeryconfig.py celery.sublime-project tasks.py test.py | |
celery celeryconfig.pyc celery.sublime-workspace tasks.pyc tornado_test.py | |
root@rabbit:~# cat celeryconfig.py | |
BROKER_URL = "librabbitmq://test:test@localhost/testvhost" | |
CELERY_RESULT_BACKEND = "amqp" | |
CELERY_DISABLE_RATE_LIMITS = True | |
CELERYD_PREFETCH_MULTIPLIER = 20 | |
CELERY_RESULT_PERSISTENT = False | |
CELERY_IMPORTS = ("tasks", ) | |
root@rabbit:~# cat tasks.py | |
from celery.task import task | |
@task() | |
def add(x, y): | |
return x + y | |
root@rabbit:~# cat test.py | |
from tasks import add | |
from multiprocessing import Process | |
from time import time | |
total = 500 | |
def test_rabbit(): | |
start = time() | |
for i in range(total): | |
result = add.delay(1,2) | |
result.get() | |
end = time() | |
spent = end - start | |
per_sec = total / spent | |
print "total: {0} {1}/sec".format( spent, per_sec) | |
print "testing" | |
test_rabbit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment