diff --git a/buildman/jobutil/buildstatus.py b/buildman/jobutil/buildstatus.py index dfb97bb40..079615812 100644 --- a/buildman/jobutil/buildstatus.py +++ b/buildman/jobutil/buildstatus.py @@ -1,6 +1,11 @@ from data.database import BUILD_PHASE from data import model +from redis import RedisError + import datetime +import logging + +logger = logging.getLogger(__name__) class StatusHandler(object): """ Context wrapper for writing status to build logs. """ @@ -24,7 +29,11 @@ class StatusHandler(object): def _append_log_message(self, log_message, log_type=None, log_data=None): log_data = log_data or {} log_data['datetime'] = str(datetime.datetime.now()) - self._build_logs.append_log_message(self._uuid, log_message, log_type, log_data) + + try: + self._build_logs.append_log_message(self._uuid, log_message, log_type, log_data) + except RedisError: + logger.exception('Could not save build log for build %s: %s', self._uuid, log_message) def append_log(self, log_message, extra_data=None): if log_message is None: @@ -64,4 +73,7 @@ class StatusHandler(object): return self._status def __exit__(self, exc_type, value, traceback): - self._build_logs.set_status(self._uuid, self._status) + try: + self._build_logs.set_status(self._uuid, self._status) + except RedisError: + logger.exception('Could not set status of build %s to %s', self._uuid, self._status)