mirror of https://gitlab.com/ita1024/waf.git
Use the same logic as Python3.5 for handling timeouts #1807
This commit is contained in:
parent
1fb3bfee6a
commit
8dba949014
|
@ -331,14 +331,15 @@ class Context(ctx):
|
|||
if Logs.verbose and not kw['shell'] and not Utils.check_exe(cmd[0]):
|
||||
raise Errors.WafError('Program %s not found!' % cmd[0])
|
||||
|
||||
wargs = {}
|
||||
cargs = {}
|
||||
if 'timeout' in kw:
|
||||
if kw['timeout'] is not None:
|
||||
wargs['timeout'] = kw['timeout']
|
||||
if kw['shell']:
|
||||
Logs.warn('Shell commands cannot timeout %r', cmd)
|
||||
del kw['timeout']
|
||||
if 'input' in kw:
|
||||
if kw['input']:
|
||||
wargs['input'] = kw['input']
|
||||
cargs['input'] = kw['input']
|
||||
kw['stdin'] = subprocess.PIPE
|
||||
del kw['input']
|
||||
|
||||
|
@ -347,7 +348,7 @@ class Context(ctx):
|
|||
kw['cwd'] = kw['cwd'].abspath()
|
||||
|
||||
try:
|
||||
ret, out, err = Utils.run_process(cmd, kw, wargs)
|
||||
ret, out, err = Utils.run_process(cmd, kw, cargs)
|
||||
except Exception as e:
|
||||
raise Errors.WafError('Execution failure: %s' % str(e), ex=e)
|
||||
|
||||
|
@ -415,14 +416,15 @@ class Context(ctx):
|
|||
if quiet is None:
|
||||
self.to_log(cmd)
|
||||
|
||||
wargs = {}
|
||||
cargs = {}
|
||||
if 'timeout' in kw:
|
||||
if kw['timeout'] is not None:
|
||||
wargs['timeout'] = kw['timeout']
|
||||
if kw['shell']:
|
||||
Logs.warn('Shell commands cannot timeout %r', cmd)
|
||||
del kw['timeout']
|
||||
if 'input' in kw:
|
||||
if kw['input']:
|
||||
wargs['input'] = kw['input']
|
||||
cargs['input'] = kw['input']
|
||||
kw['stdin'] = subprocess.PIPE
|
||||
del kw['input']
|
||||
|
||||
|
@ -431,7 +433,7 @@ class Context(ctx):
|
|||
kw['cwd'] = kw['cwd'].abspath()
|
||||
|
||||
try:
|
||||
ret, out, err = Utils.run_process(cmd, kw, wargs)
|
||||
ret, out, err = Utils.run_process(cmd, kw, cargs)
|
||||
except Exception as e:
|
||||
raise Errors.WafError('Execution failure: %s' % str(e), ex=e)
|
||||
|
||||
|
|
|
@ -866,15 +866,17 @@ def run_regular_process(cmd, kwargs, cargs={}):
|
|||
out, err = proc.communicate(**cargs)
|
||||
except TimeoutExpired:
|
||||
proc.kill()
|
||||
out, err = proc.communicate(**cargs)
|
||||
out, err = proc.communicate()
|
||||
raise TimeoutExpired(proc.args, timeout=cargs['timeout'], output=out, stderr=err)
|
||||
status = proc.returncode
|
||||
else:
|
||||
out, err = (None, None)
|
||||
try:
|
||||
status = proc.wait(**cargs)
|
||||
except TimeoutExpired:
|
||||
except TimeoutExpired as e:
|
||||
proc.kill()
|
||||
status = proc.wait(**cargs)
|
||||
proc.wait()
|
||||
raise e
|
||||
return status, out, err
|
||||
|
||||
def run_process(cmd, kwargs, cargs={}):
|
||||
|
|
|
@ -35,7 +35,8 @@ def run():
|
|||
out, err = proc.communicate(**cargs)
|
||||
except TimeoutExpired:
|
||||
proc.kill()
|
||||
out, err = proc.communicate(**cargs)
|
||||
out, err = proc.communicate()
|
||||
raise TimeoutExpired(proc.args, timeout=cargs['timeout'], output=out, stderr=err)
|
||||
ret = proc.returncode
|
||||
except Exception as e:
|
||||
exc_type, exc_value, tb = sys.exc_info()
|
||||
|
|
Loading…
Reference in New Issue