On Github kitation / celery-talk
#celery.py app = Celery("celery_test") app.config_from_object("django.conf:settings") app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
#tasks.py from models import Thing, SubThing from celery_test.celery import app @app.task def make_things(number): s = SubThing.objects.create(number=SubThing.objects.count() + 1) t = Thing(name=str(number), subthing=s) t.save() return t.id
from my_app.tasks import make_things result = make_things.delay(1) result = make_things.apply_async( args=(1,), task_id="myrandomtaskid" ) result = make_things.apply_async( (1,), link=my_callback.s() )
from my_app.tasks import make_things from celery import group tasks = [make_things.s(i) for i in xrange(5)] group_result = group(tasks).apply_async()
result.status >>> "PENDING" result.status >>> "SUCCESS" result.ready() >>> True result.get() >>> 1 group_result.completed_count() >>> 3 group_result.waiting() >>> True
@kitation