@event.listens_for(eng, 'invalidate')
def conn_invalidated(dbapi_con, con_record, exception):
    dbapi_con.close()
    raise exception
@event.listens_for(eng, 'invalidate')
def conn_invalidated(dbapi_con, con_record, exception):
    dbapi_con.close()
    raise exception