I am new to Celery (5.1.xxx) and met someone else's code using celery task doing something in database (db) and retrying when it fails.
@app.task(bind=True, max_retries=3)
def build_my_task(self, xxx)
try:
state = do_something_in_db()
except Exception as err:
raise self.retry(exc=err, countdown=RETRY_COUNTDOWN_SEC)
Now, to my understanding, timeouts in the task are related to task itself only and retry will only send signal to celery and it will start another task with restarted timeout (am I right?) , but I need to create "greater" timeout, which will fail including time of task retries (defined in task' decorator line) with maybe additional condition - say if db returned some specific state... Ho should I realize that?
Can't say I tried something, more thinking of, is Celery has some facilities for that problem and if I can get somehow time that my task will take in general (including its retries) and if I can get somehow current counter of retry attempt from inside of the task