Add timeouts to engine processes

This commit is contained in:
Brett Williams
2023-05-30 12:09:09 -05:00
parent a668fa70e5
commit 9cebcb3c62
5 changed files with 22 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ import os
import subprocess
logger = logging.getLogger()
SUBPROCESS_TIMEOUT = 5
class BaseRenderEngine(object):
@@ -18,7 +19,7 @@ class BaseRenderEngine(object):
def renderer_path(cls):
path = None
try:
path = subprocess.check_output(['which', cls.name()]).decode('utf-8').strip()
path = subprocess.check_output(['which', cls.name()], timeout=SUBPROCESS_TIMEOUT).decode('utf-8').strip()
except subprocess.CalledProcessError:
for p in cls.install_paths:
if os.path.exists(p):
@@ -36,7 +37,8 @@ class BaseRenderEngine(object):
path = cls.renderer_path()
if not path:
raise FileNotFoundError("renderer path not found")
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT).decode('utf-8')
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT,
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
return help_doc
@classmethod