Switch to Popen and adding a timeout for PESQ measurements.

After migrating to python3, the check_output doesn't return, this
CL switches to communicate() with a timeout of 2 minutes (to avoid
to block bots for 2 hours in a deadlock).

No-Presubmit: True
Bug: None
Change-Id: I3248ab090c074bd35300ca11abc08536cd797664
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250164
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Reviewed-by: Christoffer Jansson <jansson@google.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35882}
This commit is contained in:
Mirko Bonadei
2022-02-02 09:57:10 +01:00
committed by WebRTC LUCI CQ
parent 595f688b56
commit 5423c83731

View File

@ -177,9 +177,21 @@ def _RunPesq(executable_path,
# Need to provide paths in the current directory due to a bug in PESQ:
# On Mac, for some 'path/to/file.wav', if 'file.wav' is longer than
# 'path/to', PESQ crashes.
out = subprocess.check_output(_LogCommand(command),
process = subprocess.Popen(_LogCommand(command),
cwd=directory,
stderr=subprocess.STDOUT)
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
out, err = process.communicate(timeout=120)
except TimeoutExpired:
process.kill()
out, err = process.communicate()
if process.returncode != 0:
logging.error('%s (exit_code: %d)',
err.decode('utf-8').strip(), process.returncode)
return {}
# Find the scores in stdout of PESQ.
match = re.search(