mirror of https://github.com/alibaba/EasyCV.git
fix there is no error log when run in subprocess (#179)
fix there is no error log when run in subprocessfor/master
parent
80ca821518
commit
bcfb11e893
|
@ -70,7 +70,7 @@ def run_in_subprocess(cmd):
|
||||||
try:
|
try:
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
cmd, shell=True, stdout=subprocess.PIPE,
|
cmd, shell=True, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT) as return_info:
|
stderr=subprocess.PIPE) as return_info:
|
||||||
while True:
|
while True:
|
||||||
next_line = return_info.stdout.readline()
|
next_line = return_info.stdout.readline()
|
||||||
return_line = next_line.decode('utf-8', 'ignore').strip()
|
return_line = next_line.decode('utf-8', 'ignore').strip()
|
||||||
|
@ -79,9 +79,19 @@ def run_in_subprocess(cmd):
|
||||||
if return_line != '':
|
if return_line != '':
|
||||||
logging.info(return_line)
|
logging.info(return_line)
|
||||||
|
|
||||||
|
err_lines = ''
|
||||||
|
while True:
|
||||||
|
next_line = return_info.stderr.readline()
|
||||||
|
return_line = next_line.decode('utf-8', 'ignore').strip()
|
||||||
|
if return_line == '' and return_info.poll() != None:
|
||||||
|
break
|
||||||
|
if return_line != '':
|
||||||
|
logging.info(return_line)
|
||||||
|
err_lines += return_line + '\n'
|
||||||
|
|
||||||
return_code = return_info.wait()
|
return_code = return_info.wait()
|
||||||
if return_code:
|
if return_code:
|
||||||
raise subprocess.CalledProcessError(return_code, return_info)
|
raise RuntimeError(err_lines)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue