Below is the code from documentation:
from celery.exceptions import SoftTimeLimitExceeded
@celery.task(soft_time_limit=15, time_limit=20)
def mytask():
try:
return do_work()
except SoftTimeLimitExceeded:
cleanup_in_a_hurry()
The question is how celery allows to catch the exception inside the function.
If it executes my_task and raises SoftTimeLimitExceeded, how is this exception propagates inside the function?
Also, why it is not possible to catch TimeLimitExceeded inside the function?
Thank you.