According to this thread, the problem is resolved but seems like it is not . Setting Time Limit on specific task with celery
My current Celery version is 3.1.18 (Cipater).
I am trying overwrite default settings of a Task. Objective is to change the softtimelimit and hard time limit of the task because the same task is being used for multiple purposes.
Passing soft_time_limit and time_limit to MyTask constructor to change default settings.
///celery/app/ task.py
class MyTask(task.Task):
time_limit = 100
soft_time_limit = 110
max_retries = 0
def __init__(self, time_limit=None, soft_time_limit=None,
max_retries=None, *args, **kwargs):
if time_limit:
self.time_limit = time_limit
if soft_time_limit:
self.soft_time_limit = soft_time_limit
if max_retries:
self.max_retries = max_retries
task.Task.__init__(self, *args, **kwargs)
t1 = MyTask(time_limit=30, soft_time_limit=20,
max_retries=5)
or
t1 = MyTask()
t1.time_limit = 30
t1.soft_time_limit = 20
Then pass the t1.si() to task.RetryableChain(...)
job = task.RetryableChain(...)
job.delay()
When the run method is being called by worker, it still receives the old value (time_limit = 100) where as I have set time_limit = 30.
Please let me know if the issue is still exist in 3.1.18 version.