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

@@ -11,7 +11,8 @@ class FFMPEG(BaseRenderEngine):
def version(cls):
version = None
try:
ver_out = subprocess.check_output([cls.renderer_path(), '-version']).decode('utf-8')
ver_out = subprocess.check_output([cls.renderer_path(), '-version'],
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
match = re.match(".*version\s*(\S+)\s*Copyright", ver_out)
if match:
version = match.groups()[0]
@@ -21,14 +22,16 @@ class FFMPEG(BaseRenderEngine):
@classmethod
def get_encoders(cls):
encoders_raw = subprocess.check_output([cls.renderer_path(), '-encoders'], stderr=subprocess.DEVNULL).decode('utf-8')
encoders_raw = subprocess.check_output([cls.renderer_path(), '-encoders'], stderr=subprocess.DEVNULL,
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
pattern = '(?P<type>[VASFXBD.]{6})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
encoders = [m.groupdict() for m in re.finditer(pattern, encoders_raw)]
return encoders
@classmethod
def get_all_formats(cls):
formats_raw = subprocess.check_output([cls.renderer_path(), '-formats'], stderr=subprocess.DEVNULL).decode('utf-8')
formats_raw = subprocess.check_output([cls.renderer_path(), '-formats'], stderr=subprocess.DEVNULL,
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
pattern = '(?P<type>[DE]{1,2})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
formats = [m.groupdict() for m in re.finditer(pattern, formats_raw)]
return formats