How can I change arguments passed to Celery programmatically? What do I have to change in the following code:
from celery.task import PeriodicTask
class MyTask(PeriodicTask):
run_every = timedelta(seconds=1)
value = ''
def run(self, **kwargs):
print 'Passed value %s' % value
I’d like to be able to change the value property during application lifetime. The value will be probably a dictionary, but I doubt if it changes anything.
Why do you want to change the arguments? Who will pass the arguments each time? The run method is called by the Scheduler upon the specified schedule times.
You can simply read the ‘value’ from a database or whatever.
Otherwise – you might need to create your custom Scheduler class as described here: http://celery.github.com/celery/userguide/periodic-tasks.html#using-custom-scheduler-classes, and override some of its methods..