From 6cb8d5f7fce874ebbb683454ae1040f67e714c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 19 Nov 2021 23:54:57 +0100 Subject: [PATCH] Retry to convert report also on subprocess error issue10938 review370221002 (grafted from a844f8db203bb29af00836aa21c053354c18cfd3) --HG-- branch : 6.0 --- trytond/report/report.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/trytond/report/report.py b/trytond/report/report.py index e376678993..9036f1b550 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -358,14 +358,22 @@ class Report(URLMixin, PoolBase): for count in range(retry, -1, -1): if count != retry: time.sleep(0.02 * (retry - count)) - subprocess.check_call(cmd, timeout=timeout) + try: + subprocess.check_call(cmd, timeout=timeout) + except subprocess.CalledProcessError: + if count: + continue + logger.error( + "fail to convert %s to %s", report.report_name, oext, + exc_info=True) + break if os.path.exists(output): with open(output, 'rb') as fp: return oext, fp.read() else: logger.error( 'fail to convert %s to %s', report.report_name, oext) - return input_format, data + return input_format, data finally: try: os.remove(path)