From 5423c837317317ca55ff9a9d509aba2c83b683ec Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Wed, 2 Feb 2022 09:57:10 +0100 Subject: [PATCH] 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 Reviewed-by: Christoffer Jansson Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#35882} --- audio/test/low_bandwidth_audio_test.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py index 0a0a597de4..96b2be3fe9 100755 --- a/audio/test/low_bandwidth_audio_test.py +++ b/audio/test/low_bandwidth_audio_test.py @@ -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), - cwd=directory, - stderr=subprocess.STDOUT) + process = subprocess.Popen(_LogCommand(command), + cwd=directory, + 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(