changeset 852e50ac7da3 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=852e50ac7da3
description:
Add retry option to report convert
soffice fails sometimes. As it seems to be linked to the available
resources,
we retry with some delay.
issue9175
review278911002
diffstat:
CHANGELOG | 1 +
trytond/report/report.py | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r 9ae8c0921732 -r 852e50ac7da3 CHANGELOG
--- a/CHANGELOG Mon Mar 30 09:33:15 2020 +0200
+++ b/CHANGELOG Wed Apr 01 23:52:08 2020 +0200
@@ -1,3 +1,4 @@
+* Add retry option to report convert
* Add depends fields on view_attributes
* Simplify trigger action
* Run trigger in the queue
diff -r 9ae8c0921732 -r 852e50ac7da3 trytond/report/report.py
--- a/trytond/report/report.py Mon Mar 30 09:33:15 2020 +0200
+++ b/trytond/report/report.py Wed Apr 01 23:52:08 2020 +0200
@@ -5,6 +5,7 @@
import logging
import subprocess
import tempfile
+import time
import warnings
import zipfile
import operator
@@ -314,7 +315,7 @@
return data
@classmethod
- def convert(cls, report, data, timeout=5 * 60):
+ def convert(cls, report, data, timeout=5 * 60, retry=5):
"converts the report data to another mimetype if necessary"
input_format = report.template_extension
output_format = report.extension or report.template_extension
@@ -339,10 +340,13 @@
'--headless', '--nolockcheck', '--nodefault', '--norestore',
'--convert-to', oext, '--outdir', dtemp, path]
output = os.path.splitext(path)[0] + os.extsep + oext
- subprocess.check_call(cmd, timeout=timeout)
- if os.path.exists(output):
- with open(output, 'rb') as fp:
- return oext, fp.read()
+ for count in range(retry, -1, -1):
+ if count != retry:
+ time.sleep(0.02 * (retry - count))
+ subprocess.check_call(cmd, timeout=timeout)
+ 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)