Commit 63768a94 authored by Denis Bilenko's avatar Denis Bilenko

test__benchmarks.py: do not create shell, use unbuffered python, make sure subprocess is killed

parent a9ffb413
import sys import sys
import glob import glob
import mysubprocess as subprocess import subprocess
import time import time
TIMEOUT = 10 TIMEOUT = 30
def system(command): def kill(popen):
p = subprocess.Popen(command, shell=True) if popen.poll() is not None:
return
try: try:
start = time.time() popen.kill()
while time.time() < start + TIMEOUT and p.poll() is None: except OSError, ex:
if ex.errno == 3: # No such process
return
if ex.errno == 13: # Permission denied (translated from windows error 5: "Access is denied")
return
raise
def wait(popen):
end = time.time() + TIMEOUT
while popen.poll() is None:
if time.time() > end:
kill(popen)
popen.wait()
return 'TIMEOUT'
time.sleep(0.1) time.sleep(0.1)
if p.poll() is None: return popen.poll()
p.kill()
return 'KILLED'
return p.poll() def system(command):
popen = subprocess.Popen(command, shell=False)
try:
return wait(popen)
finally: finally:
if p.poll() is None: kill(popen)
p.kill()
modules = set() modules = set()
...@@ -35,10 +52,10 @@ if __name__ == '__main__': ...@@ -35,10 +52,10 @@ if __name__ == '__main__':
for path in modules: for path in modules:
sys.stderr.write(path + '\n') sys.stderr.write(path + '\n')
sys.stdout.flush() sys.stdout.flush()
command = '%s %s all' % (sys.executable, path) command = [sys.executable, '-u', path, 'all']
res = system(command) res = system(command)
if res: if res:
error = '%r failed with code %s' % (command, res) error = '%r failed with %s' % (' '.join(command), res)
sys.stderr.write(error + '\n') sys.stderr.write(error + '\n')
errors.append(error) errors.append(error)
sys.stderr.write('-----\n\n') sys.stderr.write('-----\n\n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment