diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-08 11:47:14 -0400 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-08 11:47:14 -0400 |
commit | 0a229cf5a240a1ebf4ff5d0ebb501a286bc96202 (patch) | |
tree | 2797d054788e88863d77f9826dde94fb4c276c69 /tools/jsrun.py | |
parent | 05b6aa32a5f1633797f7eae390b3a8048b29ca69 (diff) | |
parent | ae5ef852920ce67449af7693f05a767a87aed976 (diff) |
Merge branch 'incoming'
Diffstat (limited to 'tools/jsrun.py')
-rw-r--r-- | tools/jsrun.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/jsrun.py b/tools/jsrun.py index 6f77ce51..7acfc978 100644 --- a/tools/jsrun.py +++ b/tools/jsrun.py @@ -1,6 +1,8 @@ -import time +import time, os, sys, logging from subprocess import Popen, PIPE, STDOUT +TRACK_PROCESS_SPAWNS = True if (os.getenv('EM_BUILD_VERBOSE') and int(os.getenv('EM_BUILD_VERBOSE')) >= 3) else False + def timeout_run(proc, timeout, note='unnamed process', full_output=False): start = time.time() if timeout is not None: @@ -11,19 +13,25 @@ def timeout_run(proc, timeout, note='unnamed process', full_output=False): raise Exception("Timed out: " + note) out = proc.communicate() out = map(lambda o: '' if o is None else o, out) + if TRACK_PROCESS_SPAWNS: + logging.info('Process ' + str(proc.pid) + ' finished after ' + str(time.time() - start) + ' seconds.') return '\n'.join(out) if full_output else out[0] def run_js(filename, engine=None, args=[], check_timeout=False, stdin=None, stdout=PIPE, stderr=None, cwd=None, full_output=False): if type(engine) is not list: engine = [engine] command = engine + [filename] + (['--'] if 'd8' in engine[0] or 'jsc' in engine[0] else []) + args - return timeout_run( - Popen( + proc = Popen( command, stdin=stdin, stdout=stdout, stderr=stderr, - cwd=cwd), - 15*60 if check_timeout else None, + cwd=cwd) + timeout = 15*60 if check_timeout else None + if TRACK_PROCESS_SPAWNS: + logging.info('Blocking on process ' + str(proc.pid) + ': ' + str(command) + (' for ' + str(timeout) + ' seconds' if timeout else ' until it finishes.')) + return timeout_run( + proc, + timeout, 'Execution', full_output=full_output) |