Skip to content

Commit

Permalink
rollback on bad tiles or exposures.
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Aug 20, 2024
1 parent b1423eb commit 063cfe3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions py/specprodDB/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,25 @@ def main():
try:
db.dbSession.add_all(candidate_tiles)
db.dbSession.commit()
except IntegrityError:
db.log.critical("Tile %d has already been loaded!", candidate_tiles[0].tileid)
except IntegrityError as exc:
#
# IntegrityError is thrown when a tile is already loaded, but also when
# a NOT NULL constraint is violated.
#
db.log.critical("Tile %d cannot be loaded!", candidate_tiles[0].tileid)
db.log.critical("Message was: %s", exc.args[0])
db.dbSession.rollback()
return 1
db.dbSession.add_all(load_exposures)
db.dbSession.commit()
try:
db.dbSession.add_all(load_exposures)
db.dbSession.commit()
except IntegrityError as exc:
db.log.critical("Exposures for tile %d cannot be loaded!", candidate_tiles[0].tileid)
db.log.critical("Message was: %s", exc.args[0])
db.dbSession.rollback()
db.dbSession.delete(candidate_tiles[0])
db.dbSession.commit()
return 1
db.dbSession.add_all(load_frames)
db.dbSession.commit()
#
Expand Down

0 comments on commit 063cfe3

Please sign in to comment.