本文整理汇总了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()))