I have this situation where I need to pragmatically schedule a task, and the task definition requires certain input parameters each time it needs to be executed. Consider the following task function:
@task
def add_numbers(a, b):
sum = a + b
return sum
Now if I need to run the above task at two different time instances with different input parameters ex T1->add_numbers(4,5) and T2->add_numbers(2,2), how do I go about it. Thanks for the help.
ENV: Django 1.4, Celery 3.0
I encountered this problem too, and I think there is another way to help you out. the answer of @narced133 works only if the varies of params are limited, then what if we have thousands kinds of params?
solution:
refactor your celery task to accept a function as param, and the function will generate or get the params that are the real params for your celery task: add_numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With