diff --git a/queue_job/controllers/main.py b/queue_job/controllers/main.py index a93c644841..ee79f82205 100644 --- a/queue_job/controllers/main.py +++ b/queue_job/controllers/main.py @@ -32,11 +32,15 @@ def _try_perform_job(self, env, job): job.store() env.cr.commit() _logger.debug("%s started", job) + try: + job.perform() + # Triggers any stored computed fields before calling 'set_done' + # so that will be part of the 'exec_time' + env.flush_all() + except Exception: + env.cr.rollback() + raise - job.perform() - # Triggers any stored computed fields before calling 'set_done' - # so that will be part of the 'exec_time' - env.flush_all() job.set_done() job.store() env.flush_all()