Skip to content

Commit eee24a6

Browse files
committed
unoconv: add timeout to kill process after 60s
* When a libreoffice convert process takes longer than 60s, kill the process and throw an error. Libreoffice occasionally hangs indefinitely, causing MFR requests to never finish.
1 parent ffb2dae commit eee24a6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

mfr/extensions/unoconv/export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class UnoconvExporter(extension.BaseExporter):
1111

1212
def export(self):
1313
try:
14-
subprocess.check_call([
14+
subprocess.run([
1515
settings.UNOCONV_BIN,
1616
'-n',
1717
'-c', 'socket,host={},port={};urp;StarOffice.ComponentContext'.format(settings.ADDRESS, settings.PORT),
1818
'-f', self.format,
1919
'-o', self.output_file_path,
2020
'-vvv',
2121
self.source_file_path
22-
])
22+
], check=True, timeout=settings.UNOCONV_TIMEOUT)
2323
except subprocess.CalledProcessError as err:
2424
name, extension = os.path.splitext(os.path.split(self.source_file_path)[-1])
2525
raise exceptions.SubprocessError(

mfr/extensions/unoconv/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
config = settings.child('UNOCONV_EXTENSION_CONFIG')
77

88
UNOCONV_BIN = config.get('UNOCONV_BIN', '/usr/local/bin/unoconv')
9+
UNOCONV_TIMEOUT = int(config.get('UNOCONV_TIMEOUT', 60))
910

1011
ADDRESS = config.get('SERVER', os.environ.get('UNOCONV_PORT_2002_TCP_ADDR', '127.0.0.1'))
1112
PORT = config.get('PORT', os.environ.get('UNOCONV_PORT_2002_TCP_PORT', '2002'))

0 commit comments

Comments
 (0)