Eat AttributeError in peewee close database call
Fixes https://sentry.io/coreos/backend-production/issues/104257892/
This commit is contained in:
parent
7cc7e54945
commit
478b1642b2
1 changed files with 11 additions and 6 deletions
|
@ -305,6 +305,7 @@ get_epoch_timestamp_ms = lambda: int(time.time() * 1000)
|
||||||
|
|
||||||
|
|
||||||
def close_db_filter(_):
|
def close_db_filter(_):
|
||||||
|
try:
|
||||||
if not db.is_closed():
|
if not db.is_closed():
|
||||||
logger.debug('Disconnecting from database.')
|
logger.debug('Disconnecting from database.')
|
||||||
db.close()
|
db.close()
|
||||||
|
@ -312,6 +313,10 @@ def close_db_filter(_):
|
||||||
if read_slave.obj is not None and not read_slave.is_closed():
|
if read_slave.obj is not None and not read_slave.is_closed():
|
||||||
logger.debug('Disconnecting from read slave.')
|
logger.debug('Disconnecting from read slave.')
|
||||||
read_slave.close()
|
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):
|
class QuayUserField(ForeignKeyField):
|
||||||
|
|
Reference in a new issue