當前位置: 首頁>>代碼示例>>Python>>正文


Python Checker.status方法代碼示例

本文整理匯總了Python中checker.Checker.status方法的典型用法代碼示例。如果您正苦於以下問題:Python Checker.status方法的具體用法?Python Checker.status怎麽用?Python Checker.status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在checker.Checker的用法示例。


在下文中一共展示了Checker.status方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: start_test

# 需要導入模塊: from checker import Checker [as 別名]
# 或者: from checker.Checker import status [as 別名]
    def start_test(self, test):
        """
            Starts the execution of a given test. It generates the nodes and creates threads that 
            send tasks to the cluster's nodes and wait for the result.
            @type test: Test 
            @param test: a Test object containing the test's parameters (nodes, matrix, 
                        tasks etc)
        """
       
        self.safe_print("**************** Start Test %s *****************"%test.name)

        checker = Checker() 
        checker.add_banned_thread(current_thread())
        
        self.num_correct_results = 0
        
        num_nodes = test.num_nodes
        matrix_size = len(test.matrix1)
        block_size = test.get_stored_block_dim()
        
        nodes = []
        data_stores = [] 
        n = matrix_size / block_size

        for i in range(n):
            for j in range(n):

                # create data store and its blocks
                
                block1 = []
                block2 = []

                for k in range(block_size):
                    block1.append(test.matrix1[i*block_size+k][j*block_size:(j+1)*block_size])
                    block2.append(test.matrix2[i*block_size+k][j*block_size:(j+1)*block_size])

                data_store = DataStore(block1, block2, 5, 0, 0, checker)
                data_stores.append(data_store)
            
                # create nodes
                nodes.append(Node(  (i,j),      # node_ID
                                    block_size, 
                                    matrix_size, 
                                    data_store))

        # the nodes need to know about each other

        for node in nodes:
            node.set_nodes(nodes)

        # send tasks to nodes

        tasks = test.tasks
        threads = []
        for task in tasks:
            if len(task) != 5: 
                break
            index = task[0][0] * n + task[0][1]
            t = Thread(target=Tester.start_node, args=(self, nodes[index], task, test))
            checker.add_banned_thread(t)
            
            t.start()
            threads.append(t)
            
            
        for t in threads:
            t.join()

        for node in nodes:
            node.shutdown()
        
        errors = checker.status()
        for error in errors:
            self.print_error(error)

        if not len(errors) and self.num_correct_results == len(tasks):
            self.passed_tests += 1
            self.safe_print("Correct result")
        
        self.safe_print(("**************** End Test %s *******************\n" % test.name) + ("Remaining threads: %d" % active_count()))
開發者ID:LaitaStefan,項目名稱:labs-2014,代碼行數:82,代碼來源:tester.py


注:本文中的checker.Checker.status方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。