From c0b4c4a3c4dc6f160ab46467d1d021626801f982 Mon Sep 17 00:00:00 2001 From: "kjellander@webrtc.org" Date: Wed, 2 Oct 2013 15:04:45 +0000 Subject: [PATCH] Workaround issue with stdin on Windows. On Windows, sometimes the compare_videos.py script fails because the inherited stdin handle from the parent process fails. It seems we can work around this by passing null to stdin to the subprocesses, since we're not using it anyway. The errors looked like this: Traceback (most recent call last): File "C:\b\build\slave\Win7_Tester\build\src\third_party/webrtc/tools/compare_videos.py", line 116, in sys.exit(main()) File "C:\b\build\slave\Win7_Tester\build\src\third_party/webrtc/tools/compare_videos.py", line 91, in main barcode_decoder = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) File "C:\b\depot_tools\python_bin\lib\subprocess.py", line 588, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\b\depot_tools\python_bin\lib\subprocess.py", line 686, in _get_handles p2cread = GetStdHandle(STD_INPUT_HANDLE) WindowsError: [Error 6] The handle is invalid Example from http://build.chromium.org/p/chromium.webrtc/builders/Win7%20Tester/builds/4498/steps/webrtc_manual_browser_tests_test/logs/stdio BUG=302915 TEST=successful runs on Windows and Linux. R=phoglund@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2334005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4902 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/tools/compare_videos.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webrtc/tools/compare_videos.py b/webrtc/tools/compare_videos.py index afdd6a467b..ee8e6d5122 100755 --- a/webrtc/tools/compare_videos.py +++ b/webrtc/tools/compare_videos.py @@ -80,6 +80,11 @@ def main(): # Run barcode decoder on the test video to identify frame numbers. path_to_decoder = os.path.join(SCRIPT_DIR, 'barcode_tools', 'barcode_decoder.py') + + # On Windows, sometimes the inherited stdin handle from the parent process + # fails. Work around this by passing null to stdin to the subprocesses. + null_filehandle = open(os.devnull, 'r') + cmd = [ sys.executable, path_to_decoder, @@ -88,7 +93,8 @@ def main(): '--yuv_frame_height=%d' % options.yuv_frame_height, '--stats_file=%s' % options.stats_file, ] - barcode_decoder = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) + barcode_decoder = subprocess.Popen(cmd, stdin=null_filehandle, + stdout=sys.stdout, stderr=sys.stderr) barcode_decoder.wait() if barcode_decoder.returncode != 0: print 'Failed to run barcode decoder script.' @@ -104,7 +110,8 @@ def main(): '--width=%d' % options.yuv_frame_width, '--height=%d' % options.yuv_frame_height, ] - frame_analyzer = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) + frame_analyzer = subprocess.Popen(cmd, stdin=null_filehandle, + stdout=sys.stdout, stderr=sys.stderr) frame_analyzer.wait() if frame_analyzer.returncode != 0: print 'Failed to run frame analyzer.'