From 119fda07ea998fbaee1969769407d6b27da74473 Mon Sep 17 00:00:00 2001 From: fishpepper Date: Tue, 20 Dec 2016 16:05:46 +0100 Subject: [PATCH] fix hang in subprocess.Popen / subprocess.wait() --- foedus-core/tools/cpplint-wrapper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/foedus-core/tools/cpplint-wrapper.py b/foedus-core/tools/cpplint-wrapper.py index 7ccb1eb2..053ef07e 100644 --- a/foedus-core/tools/cpplint-wrapper.py +++ b/foedus-core/tools/cpplint-wrapper.py @@ -13,6 +13,7 @@ import subprocess import sys import time +import tempfile import unicodedata @@ -177,14 +178,18 @@ def exec_cpplint(files, cpplint_arguments): sys.stdout.write('Launching cpplint for ' + str(len(index_now)) + ' files.\n') # sys.stdout.write('arguments: ' + ' '.join(args) + '\n') # sys.stdout.write('Launching cpplint (' + cpplint_file + ') for ' + str(len(files)) - # + ' files. arguments: ' + ' '.join(args) + '\n') - proc = subprocess.Popen(args, bufsize=65536, stderr=subprocess.PIPE, close_fds=True) + # + ' files. arguments: ' + ' '.join(args) + '\n') + + tmpfile = tempfile.TemporaryFile() + proc = subprocess.Popen(args, bufsize=65536, stderr=tmpfile, close_fds=True) proc.wait() + # go to first line of tmpfile + tmpfile.seek(0) has_error = False clean_index = {} clean_index.update(index_last) clean_index.update(index_now) - for line in proc.stderr: + for line in tmpfile: # This is annoying. Why cpplint writes this to _stderr_?? if not line.startswith("Done processing "): has_error = True