Use a more pro-active approach to identify an uninitialized db proxy.

This commit is contained in:
Jake Moshenko 2017-07-26 18:23:05 -04:00
parent d2dc3c40bf
commit e9a5fdbad1

View file

@ -323,18 +323,13 @@ get_epoch_timestamp_ms = lambda: int(time.time() * 1000)
def close_db_filter(_):
try:
if not db.is_closed():
if db.obj is not None and not db.is_closed():
logger.debug('Disconnecting from database.')
db.close()
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):