Monday, 15 February 2010

python - Celery: how to add a callback function when calling a remote task (with send_task) -



python - Celery: how to add a callback function when calling a remote task (with send_task) -

you can utilize celery phone call task name, registered in different process (or on different machine):

celery.send_task(task_name, args=args, kwargs=kwargs)

(http://celery.readthedocs.org/en/latest/reference/celery.html#celery.celery.send_task)

i able add together callback executed task finished , executed within process calling task.

my setup

i have server a, runs django powered website , utilize basic celery setup described here. don't run celery worker on server a.

then there server b, runs (several) celery worker.

so far, setup seems work pretty good. can send tasks on server , executed on remote server b.

the problem

the problem is, i'm not able add together callback function.

in docs says, can add together callback providing follow-up task. this:

@celery.task def result_handler(result): print "yeah" celery.send_task(task_name, args=args, kwargs=kwargs, link=result_handler.s())

this means, have start worker on server registers task "result_handler". , if that, handler called in process spawned worker , not django process, calling task.

the solution able come endless loop checks every 2 seconds if task ready or not, think there should simpler solution.

python django multiprocessing celery

No comments:

Post a Comment