diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-26 10:06:07 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-26 10:06:07 -0700 |
commit | ebfb4a9f2d9735f74e0c65dc1771849bbe178b63 (patch) | |
tree | 1fb2029c7ad2aaf057c98ae2fd393a56be2f70ab /tools/jsrun.py | |
parent | 252317cd60608018be78c8462d72286a3b91a2b5 (diff) | |
parent | 99dcc4eec235eba633303e59176723a048f8d036 (diff) |
Merge pull request #1631 from juj/responsive_logging
Responsive logging
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) |