Merge pull request #2828 from jakedt/attribs

Use a more pro-active approach to identify an uninitialized db proxy.
This commit is contained in:
Jake Moshenko 2017-07-26 18:25:10 -04:00 committed by GitHub
commit 90ed0c28be

View file

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