src/dirbs/metadata.py
def log_job_failure(conn, job_command, run_id, logger):
    """
    Log metadata indicating that the job specified by job_command and run_id failed to complete.

    Arguments:
        conn: dirbs db connection object
        job_command: command name of the currently running job
        run_id: id of the currently running job
        logger: dirbs logger instance
    Raises:
        psycopg2.InterfaceError, psycopg2.OperationalError: if anything goes wrong while logging the activity
    """
    # An auto-commit connection must be used to ensure the log is not rolled back due to any reason, it
    # must be preserved.
    assert conn.autocommit
    sio = io.StringIO()
    etype, value, tb = sys.exc_info()
    traceback.print_exception(etype, value, tb, None, sio)
    exception_string = sio.getvalue()
    sio.close()
    try:
        with conn.cursor() as cursor:
            cursor.execute("""UPDATE job_metadata
                                 SET end_time = NOW(),
                                     status = 'error',
                                     exception_info = %s
                               WHERE command = %s
                                 AND run_id = %s""",
                           [exception_string, job_command, run_id])
            assert cursor.rowcount == 1
    except (psycopg2.InterfaceError, psycopg2.OperationalError) as e:
        logger.error('Failed to log job failure due to DB exception: {0}'.format(str(e)))

    Log metadata indicating that the job specified by job_command and run_id failed to complete.

    Arguments:
        conn: dirbs db connection object
        job_command: command name of the currently running job
        run_id: id of the currently running job
        logger: dirbs logger instance
    Raises:
        psycopg2.InterfaceError, psycopg2.OperationalError: if anything goes wrong while logging the activity
    
Log metadata indicating that the job specified by job_command and run_id failed to complete.
Log metadata indicating that the job specified by job_command and run_id failed to complete .
def log_job_failure(conn, job_command, run_id, logger):
    assert conn.autocommit
    sio = io.StringIO()
    etype, value, tb = sys.exc_info()
    traceback.print_exception(etype, value, tb, None, sio)
    exception_string = sio.getvalue()
    sio.close()
    try:
        with conn.cursor() as cursor:
            cursor.execute("""UPDATE job_metadata
                                 SET end_time = NOW(),
                                     status = 'error',
                                     exception_info = %s
                               WHERE command = %s
                                 AND run_id = %s""",
                           [exception_string, job_command, run_id])
            assert cursor.rowcount == 1
    except (psycopg2.InterfaceError, psycopg2.OperationalError) as e:
        logger.error('Failed to log job failure due to DB exception: {0}'.format(str(e)))
def log_job_failure ( conn , job_command , run_id , logger ) : assert conn . autocommit sio = io . StringIO ( ) etype , value , tb = sys . exc_info ( ) traceback . print_exception ( etype , value , tb , None , sio ) exception_string = sio . getvalue ( ) sio . close ( ) try : with conn . cursor ( ) as cursor : cursor . execute ( """UPDATE job_metadata
                                 SET end_time = NOW(),
                                     status = 'error',
                                     exception_info = %s
                               WHERE command = %s
                                 AND run_id = %s""" , [ exception_string , job_command , run_id ] ) assert cursor . rowcount == 1 except ( psycopg2 . InterfaceError , psycopg2 . OperationalError ) as e : logger . error ( 'Failed to log job failure due to DB exception: {0}' . format ( str ( e ) ) )
Log metadata indicating that the job specified by job_command and run_id failed to complete.
Log metadata indicating that the job specified by job_command and run_id failed to complete .
"""
    Log metadata indicating that the job specified by job_command and run_id failed to complete.

    Arguments:
        conn: dirbs db connection object
        job_command: command name of the currently running job
        run_id: id of the currently running job
        logger: dirbs logger instance
    Raises:
        psycopg2.InterfaceError, psycopg2.OperationalError: if anything goes wrong while logging the activity
    """ # An auto-commit connection must be used to ensure the log is not rolled back due to any reason, it # must be preserved.
if anything goes wrong while logging the activity
if anything goes wrong while logging the activity
psycopg2.InterfaceError, psycopg2.OperationalError
conn
dirbs db connection object
dirbs db connection object
job_command
command name of the currently running job
command name of the currently running job
run_id
id of the currently running job
id of the currently running job
logger
dirbs logger instance
dirbs logger instance