changeset e81588dd7ee4 in trytond:6.2
details: https://hg.tryton.org/trytond?cmd=changeset&node=e81588dd7ee4
description:
        Retry to convert report also on subprocess error

        issue10938
        review370221002
        (grafted from a844f8db203bb29af00836aa21c053354c18cfd3)
diffstat:

 trytond/report/report.py |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 2b2076ba064b -r e81588dd7ee4 trytond/report/report.py
--- a/trytond/report/report.py  Sat Nov 20 13:40:49 2021 +0100
+++ b/trytond/report/report.py  Fri Nov 19 23:54:57 2021 +0100
@@ -372,14 +372,22 @@
             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)

Reply via email to