Skip to Main Content

Announcements

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

python thread was stopped without exception message

user-y6j2zAug 12 2023

I'm using Python on Raspberry Pi. And I'm using JDBC to connect to the Oracle database. The problem is that sometimes the thread shuts down while I'm connecting to JDBC. The code is enclosed in a try exception syntax, but the thread is terminated without leaving any exception logs.The reason could not be found because there was no log left. Is there a problem with using JDBC?

def connect_A_db(self):
    print('Connect a oracle.db\n')
    try :
        start_time = time.time()
        conn = jaydebeapi.connect("oracle.jdbc.driver.OracleDriver", dsn, [user, password], jdbc_path)
        period = (time.time() - start_time)
        print("conn_period: " + str(period))
        return conn
    except Exception as ex:
        period = (time.time() - start_time)
        print("conn_period: " + str(period))
        print(str(ex))
        return -1

def A_client_function_send_data(self, msg):
    ret = -1
    try :
        print("start conn")
        t1 = time.time()
        conn = self.connect_A_db()
        if conn != -1:
            cursor = conn.cursor() 
            cursor.execute(msg)
            ret = 0                 
            if isinstance(conn, jaydebeapi.Connection):
                conn.commit()
                conn.close()

                print("%s" %(msg))
                self.logger.debug("%s, ret: %s, %s" %(msg, str(ret), str(time.time() - t1)))
        else:
            ret = -1         

    except jaydebeapi.DatabaseError as e:
        print(f"Insert Error: {e}")
        self.logger.error(f"Insert Error: {e}")
        conn.rollback()
        
    except Exception as ex:
        self.exh.systemError(traceback.format_exc())
        self.logger.error("Exception: " + str(ex))
        print(ex)
        ret = -1
            
    finally :
        print("send ret: "+ str(ret))               
        return ret

Based on what remains in the log, the thread is terminated before

self.logger.debug ("%s, ret: %s, %s"% (msg, str(ret), str(time.time() - t1)))

runs.

Comments
Post Details
Added on Aug 12 2023
0 comments
343 views