Softtimeout and timeout in celery tasks not working
I have a task that takes 20 seconds on average. I want to set soft and hard timeout for this task. I define it like this:
@app.task(ignore_result=True, timeout=100, soft_timeout=50)
def MYTASK(SOMEPARAMS):
# MYTASK
But it doesn't work. I am testing it with these parameters:
@app.task(ignore_result=True, timeout=1, soft_timeout=1)
def MYTASK(SOMEPARAMS):
# MYTASK
But my tasks are working correctly and they take time for 1 second, while this should never be done.
why is the timeout not working?
Edit : When I use 1s timeout in my log I see printouts like this:
[2014-08-22 12:51:00,003: INFO/MainProcess] Task MYTASK[56002e72-a093-46c6-86cd-4c7b7e6ea7c3] succeeded in 15.549023876s: None
+3
source to share
1 answer
Use time_limit
and soft_time_limit
parameters:
@task(time_limit=2, soft_time_limit=1)
def mytask():
pass
Also note that:
Time limits do not currently work on Windows and other platforms that do not support the SIGUSR1 signal.
+2
source to share