Reschedule task failing for operational errors
We should always try to execute them later as operational errors should be temporary. issue9252 review319301002
This commit is contained in:
1 parent
53264d2928
commit
ab161982e9
1 file changed
+13
@@ -1,6 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import datetime as dt
|
||||
import logging
|
||||
import random
|
||||
import select
|
||||
import signal
|
||||
import time
|
||||
@@ -117,5 +119,16 @@ def run_task(pool, task_id):
|
||||
continue
|
||||
raise
|
||||
logger.info('task "%d" done', task_id)
|
||||
except backend.DatabaseOperationalError:
|
||||
try:
|
||||
with Transaction().start(pool.database_name, 0) as transaction:
|
||||
task = Queue(task_id)
|
||||
scheduled_at = dt.datetime.now()
|
||||
scheduled_at += dt.timedelta(
|
||||
seconds=random.randint(0, 2 ** retry))
|
||||
Queue.push(task.name, task.data, scheduled_at=scheduled_at)
|
||||
except Exception:
|
||||
logger.critical(
|
||||
'rescheduling task "%d" failed', task_id, exc_info=True)
|
||||
except Exception:
|
||||
logger.critical('task "%d" failed', task_id, exc_info=True)
|
||||
Reference in new issue
Block a user