def test_facade(self):
     logger = MyLogger()
     logger.warn("Facade works!")
     logger.read()
     self.assertTrue(True)
Beispiel #2
0
            conn = SQLConnManager.Connect()
            acquired = global_vars["sql_lock"].acquire()
            try:
                global_vars["sql_connection_num"] += 1
            except Exception, e:
                logger.error("Exception: %s" % str(e))
            finally:
                if acquired:
                    global_vars["sql_lock"].release()
            logger.debug(
                "Created a new SQL database connection in pid (%s), we have %d live connections"
                % (os.getpid(), global_vars["sql_connection_num"]))

        if conn is None:
            logger.warn(
                "%d live connections currently are in the system, this request will be blocked"
                % global_vars["sql_connection_num"])
            global_vars["sql_connections"].get(block=True)
            logger.warn(
                "%d live connections currently are in the system, the blocked request has been released"
                % global_vars["sql_connection_num"])
        return conn

    @staticmethod
    def ReturnConnection(conn):
        if conn is not None:
            connected = SQLConnManager.TestSQLConnection(conn)
            acquired = global_vars["sql_lock"].acquire()
            returnedConn = False
            try:
                if connected: