def make_threaded(function, args, node_labels): threads = [] list_args = list(args) for node_label in node_labels: list_args.insert(0, node_label) thread = KThread(target=function, args=tuple(list_args)) threads.append(thread) list_args.pop(0) for thread in threads: thread.start() for thread in threads: thread.join()
def make_threaded(function, args, nodes): '''Launch fuction in threads. Number of thread equal to number of cluster nodes. Args: function: Threaded function. args: Threaded function arguments. node_map: Cluster nodes map. ''' threads = [] list_args = list(args) for node in nodes.values(): list_args.insert(0, node) thread = KThread(target=function, args=tuple(list_args)) threads.append(thread) list_args.pop(0) for thread in threads: thread.start() for thread in threads: thread.join()