Difference between send_task and apply_async in Celery, Flask when I used send_task along with queue name is not working

Viewed 14

Though the syntax is different for send_task and apply_task methods, they have the similar arguments. send_task with queue name is not working where as it is working with apply_async.

task_routes={'celery_tasks.send_email': {'queue': 'email'}})

What could be the difference? Documentation says both the methods are same.

1 Answers

They are actually fundamentally different. For apply_async() to work you need your task(s) definition(s) to be available. send_task() will send task with args and kwargs to the particular queue, and return result if workers subscribed to that queue know how to execute that particular task (if it is registered).

This makes send_task() superuseful if you do not want to share the code with producers. I use this in many places.

Related