Make sure to not hold DB connections open in the new build manager

This commit is contained in:
Joseph Schorr 2015-01-29 14:40:24 -05:00
parent 84ba5d5f23
commit cf35da30bc
2 changed files with 29 additions and 17 deletions

View file

@ -1,5 +1,6 @@
from data.database import BUILD_PHASE
from data.database import BUILD_PHASE, UseThenDisconnect
from data import model
from app import app
class StatusHandler(object):
""" Context wrapper for writing status to build logs. """
@ -43,9 +44,11 @@ class StatusHandler(object):
self._append_log_message(phase, self._build_logs.PHASE, extra_data)
# Update the repository build with the new phase
repo_build = model.get_repository_build(self._uuid)
repo_build.phase = phase
repo_build.save()
with UseThenDisconnect(app.config):
repo_build = model.get_repository_build(self._uuid)
repo_build.phase = phase
repo_build.save()
return True
def __enter__(self):