2
from subprocess import Popen, PIPE, STDOUT
4
def timeout_run(proc, timeout, note='unnamed process', full_output=False):
6
if timeout is not None:
7
while time.time() - start < timeout and proc.poll() is None:
9
if proc.poll() is None:
10
proc.kill() # XXX bug: killing emscripten.py does not kill it's child process!
11
raise Exception("Timed out: " + note)
12
out = proc.communicate()
13
return '\n'.join(out) if full_output else out[0]
15
def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None, full_output=False):
16
if type(engine) is not list:
18
command = engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args
25
15*60 if check_timeout else None,
27
full_output=full_output)