Beispiel #1
0
                    "An existing database connection in the connection pool has been disconnected by remote server, recreate a new connection. we have %d live connections"
                    % global_vars["sql_connection_num"])
                try:
                    conn.close()
                except:
                    pass
                conn = SQLConnManager.Connect()

        if conn is None and global_vars[
                "sql_connection_num"] <= sql_max_connect_num:
            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"])