From 73ebcd45e3e273d21baad73adc2736186f7f5925 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 11 Dec 2014 21:10:54 +0200 Subject: [PATCH] Only perform the heartbeat check if the build is actually running. If it has completed, or has an error, then we know it is done. --- endpoints/api/build.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/endpoints/api/build.py b/endpoints/api/build.py index d8ab952f8..e7fdf2f11 100644 --- a/endpoints/api/build.py +++ b/endpoints/api/build.py @@ -70,10 +70,11 @@ def build_status_view(build_obj, can_write=False): # If the status contains a heartbeat, then check to see if has been written in the last few # minutes. If not, then the build timed out. - if status is not None and 'heartbeat' in status and status['heartbeat']: - heartbeat = datetime.datetime.fromtimestamp(status['heartbeat']) - if datetime.datetime.now() - heartbeat > datetime.timedelta(minutes=1): - phase = database.BUILD_PHASE.INTERNAL_ERROR + if phase != database.BUILD_PHASE.COMPLETE and phase != database.BUILD_PHASE.ERROR: + if status is not None and 'heartbeat' in status and status['heartbeat']: + heartbeat = datetime.datetime.fromtimestamp(status['heartbeat']) + if datetime.datetime.now() - heartbeat > datetime.timedelta(minutes=1): + phase = database.BUILD_PHASE.INTERNAL_ERROR logger.debug('Can write: %s job_config: %s', can_write, build_obj.job_config) resp = {