Eat AttributeError in peewee close database call

Fixes https://sentry.io/coreos/backend-production/issues/104257892/
This commit is contained in:
Joseph Schorr 2017-02-21 14:27:31 -05:00
parent 7cc7e54945
commit 478b1642b2

View file

@ -305,6 +305,7 @@ get_epoch_timestamp_ms = lambda: int(time.time() * 1000)
def close_db_filter(_):
try:
if not db.is_closed():
logger.debug('Disconnecting from database.')
db.close()
@ -312,6 +313,10 @@ def close_db_filter(_):
if read_slave.obj is not None and not read_slave.is_closed():
logger.debug('Disconnecting from read slave.')
read_slave.close()
except AttributeError:
# If the database is closed between the time we check on line 309 and db.close() is called on
# 311, then an AttributeError will be raised. Simply eat this exception and continue onward.
pass
class QuayUserField(ForeignKeyField):