diff --git a/category/get_net_info.py b/category/get_net_info.py index fd5394c1569a15b41f590313e55e62c8acdc4402..82be64ada9f0669f4453fe45db2f3c71da0c49f1 100644 --- a/category/get_net_info.py +++ b/category/get_net_info.py @@ -5,6 +5,7 @@ import os import sys +from common.customizefunctionthread import CustomizeFunctionThread if sys.getdefaultencoding() != 'utf-8': reload(sys) @@ -136,6 +137,23 @@ class NetInfo: return Command.cmd_write_file(res, self.__default_file_name) + def __multi_threads_get_info(self, funcs, interval, times): + ''' + Multithreaded fetching information function + funcs: The name of the function that requires multithreading to start + ''' + res = '' + tasks = [] + for func in funcs: + task = CustomizeFunctionThread(func, (interval, times)) + task.start() + tasks.append(task) + + for task in tasks: + task.join() + res = res + task.get_result() + return res + def __get_sar_DEV_task1(self, interval, times): # print("Sar_dev task 1 started") # get "sar -n DEV" command info