Skip to content

Commit

Permalink
BLD: Don't leave the build task running if runtests.py is interrupted
Browse files Browse the repository at this point in the history
Without this, my powershell terminal would block on the build completing.

This already matches the logic in the log-less case
  • Loading branch information
eric-wieser committed Jul 1, 2018
1 parent f85bf17 commit b6bbdee
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b6bbdee

Please sign in to comment.