当前位置: 首页>>代码示例>>Python>>正文


Python Checker.add_banned_thread方法代码示例

本文整理汇总了Python中checker.Checker.add_banned_thread方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.add_banned_thread方法的具体用法?Python Checker.add_banned_thread怎么用?Python Checker.add_banned_thread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在checker.Checker的用法示例。


在下文中一共展示了Checker.add_banned_thread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_test

# 需要导入模块: from checker import Checker [as 别名]
# 或者: from checker.Checker import add_banned_thread [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.add_banned_thread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。