src/dirbs/cli/classify.py
def _do_final_cleanup(conn, logger, is_locked, tables_to_delete):
    """
    Function to perform final cleanup to remove intermediate tables and release locks.

    :param conn: database connection obj
    :param logger: dirbs logger obj
    :param is_locked: bool (to check if there is postgres advisory lock)
    :param tables_to_delete: list of tables to delete
    """
    if is_locked:
        with conn.cursor() as cursor:
            cursor.execute('SELECT pg_advisory_unlock(%s::BIGINT)', [hash_string_64bit('dirbs-classify')])

    with conn.cursor() as cursor:
        remaining_tables_to_delete = copy.copy(tables_to_delete)
        for t in tables_to_delete:
            try:
                cursor.execute(sql.SQL('DROP TABLE IF EXISTS {0} CASCADE').format(sql.Identifier(t)))
                conn.commit()
                remaining_tables_to_delete.remove(t)
            except:  # noqa: E722
                for t_not_deleted in remaining_tables_to_delete:
                    logger.warning('Failed to drop table {0} due to exception. Please issue '
                                   "\'DROP TABLE IF EXISTS {0}\' manually!".format(t_not_deleted))
                raise

    Function to perform final cleanup to remove intermediate tables and release locks.

    :param conn: database connection obj
    :param logger: dirbs logger obj
    :param is_locked: bool (to check if there is postgres advisory lock)
    :param tables_to_delete: list of tables to delete
    
Function to perform final cleanup to remove intermediate tables and release locks.
Function to perform final cleanup to remove intermediate tables and release locks .
def _do_final_cleanup(conn, logger, is_locked, tables_to_delete):
    if is_locked:
        with conn.cursor() as cursor:
            cursor.execute('SELECT pg_advisory_unlock(%s::BIGINT)', [hash_string_64bit('dirbs-classify')])
    with conn.cursor() as cursor:
        remaining_tables_to_delete = copy.copy(tables_to_delete)
        for t in tables_to_delete:
            try:
                cursor.execute(sql.SQL('DROP TABLE IF EXISTS {0} CASCADE').format(sql.Identifier(t)))
                conn.commit()
                remaining_tables_to_delete.remove(t)
            except:  
                for t_not_deleted in remaining_tables_to_delete:
                    logger.warning('Failed to drop table {0} due to exception. Please issue '
                                   "\'DROP TABLE IF EXISTS {0}\' manually!".format(t_not_deleted))
                raise
def _do_final_cleanup ( conn , logger , is_locked , tables_to_delete ) : if is_locked : with conn . cursor ( ) as cursor : cursor . execute ( 'SELECT pg_advisory_unlock(%s::BIGINT)' , [ hash_string_64bit ( 'dirbs-classify' ) ] ) with conn . cursor ( ) as cursor : remaining_tables_to_delete = copy . copy ( tables_to_delete ) for t in tables_to_delete : try : cursor . execute ( sql . SQL ( 'DROP TABLE IF EXISTS {0} CASCADE' ) . format ( sql . Identifier ( t ) ) ) conn . commit ( ) remaining_tables_to_delete . remove ( t ) except : for t_not_deleted in remaining_tables_to_delete : logger . warning ( 'Failed to drop table {0} due to exception. Please issue ' "\'DROP TABLE IF EXISTS {0}\' manually!" . format ( t_not_deleted ) ) raise
Function to perform final cleanup to remove intermediate tables and release locks.
Function to perform final cleanup to remove intermediate tables and release locks .
"""
    Function to perform final cleanup to remove intermediate tables and release locks.

    :param conn: database connection obj
    :param logger: dirbs logger obj
    :param is_locked: bool (to check if there is postgres advisory lock)
    :param tables_to_delete: list of tables to delete
    """ # noqa: E722
conn
database connection obj
database connection obj
logger
dirbs logger obj
dirbs logger obj
is_locked
bool (to check if there is postgres advisory lock)
bool ( to check if there is postgres advisory lock )
tables_to_delete
list of tables to delete
list of tables to delete