diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-07-01 12:01:42 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-07-01 12:07:28 -0700 |
commit | b6bbdee40c3e258d2d5fcd3e99d651275f720f18 (patch) | |
tree | 36130ba6b88caae33081bb4aad597c0dfb5d07f9 /runtests.py | |
parent | f85bf1776b86d306132e310e8152448d4ca452cc (diff) | |
download | numpy-b6bbdee40c3e258d2d5fcd3e99d651275f720f18.tar.gz |
BLD: Don't leave the build task running if runtests.py is interrupted
Without this, my powershell terminal would block on the build completing.
This already matches the logic in the log-less case
Diffstat (limited to 'runtests.py')
-rwxr-xr-x | runtests.py | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/runtests.py b/runtests.py index 35717b319..355173326 100755 --- a/runtests.py +++ b/runtests.py @@ -384,23 +384,27 @@ def build_project(args): with open(log_filename, 'w') as log: p = subprocess.Popen(cmd, env=env, stdout=log, stderr=log, cwd=ROOT_DIR) - - # Wait for it to finish, and print something to indicate the - # process is alive, but only if the log file has grown (to - # allow continuous integration environments kill a hanging - # process accurately if it produces no output) - last_blip = time.time() - last_log_size = os.stat(log_filename).st_size - while p.poll() is None: - time.sleep(0.5) - if time.time() - last_blip > 60: - log_size = os.stat(log_filename).st_size - if log_size > last_log_size: - print(" ... build in progress") - last_blip = time.time() - last_log_size = log_size - - ret = p.wait() + try: + # Wait for it to finish, and print something to indicate the + # process is alive, but only if the log file has grown (to + # allow continuous integration environments kill a hanging + # process accurately if it produces no output) + last_blip = time.time() + last_log_size = os.stat(log_filename).st_size + while p.poll() is None: + time.sleep(0.5) + if time.time() - last_blip > 60: + log_size = os.stat(log_filename).st_size + if log_size > last_log_size: + print(" ... build in progress") + last_blip = time.time() + last_log_size = log_size + + ret = p.wait() + except: + p.kill() + p.wait() + raise if ret == 0: print("Build OK") |