I have a task that takes 20 seconds in 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 really. I test it with this params:
@app.task(ignore_result=True, timeout=1, soft_timeout=1)
def MYTASK(SOMEPARAMS):
# MYTASK
But my tasks work correctly and them takes times over 1 seconds while it should never be done.
why timeout doesn't work?
Edit: When I use 1 sec timeout in my log I see prints like this:
[2014-08-22 12:51:00,003: INFO/MainProcess] Task MYTASK[56002e72-a093-46c6-86cd-4c7b7e6ea7c3] succeeded in 15.549023876s: None
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.
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