0

Need to add the dynamic soft_time_limit for my task. The task should be executed based on dynamic soft_time_limit. I should not mention a limit for this execution. Is there any way to define this?

@APP.task(acks_late=True, soft_time_limit=10000, trail=True, bind=True)
def execute_fun(self, data):
    try:
        do_work()
    except Exception as error:
        print('---error---', error)

Here in the above function, I don't want to define the soft_time_limit, It should take it as a dynamic time limit. How should I achieve this?

Hushen
  • 427
  • 1
  • 4
  • 15
  • I do not think it is possible. I hope I am wrong. – DejanLekic Jan 04 '21 at 17:31
  • Check out https://stackoverflow.com/a/11678102/5832540 – Tomáš Linhart Jan 05 '21 at 13:59
  • @TomášLinhart in this also they have mentioned soft_time_limit=10000, so we don't want this hardcoded 10000 value. It should take a dynamic time limit according to the task. – Hushen Jan 05 '21 at 15:05
  • @Hushen The most upvoted answer mentions that you can pass the value as an argument to `apply_async`, thus specifying it dynamically. – Tomáš Linhart Jan 05 '21 at 15:24
  • mytask.apply_async(args=[], kwargs={}, time_limit=30, soft_time_limit=10) what happen when my task is not completed in 10 seconds?. anyhow I have mentioned as parameter soft_time_limit=10 – Hushen Jan 05 '21 at 15:30

0 Answers0