Clarify why we need database.UserThenDisconnect

This commit is contained in:
Joseph Schorr 2015-02-05 15:00:19 -05:00
parent 555bd293ea
commit bc119aed22

View file

@ -61,6 +61,9 @@ def _sign_sythentic_image(verb, linked_storage_uuid, queue_file):
logger.exception('Exception when signing %s image %s', verb, linked_storage_uuid)
return
# Setup the database (since this is a new process) and then disconnect immediately
# once the operation completes.
if not queue_file.raised_exception:
with database.UseThenDisconnect(app.config):
try:
derived = model.get_storage_by_uuid(linked_storage_uuid)
@ -89,6 +92,8 @@ def _write_synthetic_image_to_storage(verb, linked_storage_uuid, linked_location
queue_file.close()
if not queue_file.raised_exception:
# Setup the database (since this is a new process) and then disconnect immediately
# once the operation completes.
with database.UseThenDisconnect(app.config):
done_uploading = model.get_storage_by_uuid(linked_storage_uuid)
done_uploading.uploading = False