diff --git a/common/threadpool.py b/common/threadpool.py index 8a613a97f211d8e951acbef750d8856db19a79e2..c199fd8db6b899fdd0dd3f438fbe64d4bb55d5c4 100644 --- a/common/threadpool.py +++ b/common/threadpool.py @@ -2,6 +2,7 @@ #!/usr/bin/env python # cython:language_level=3 +import functools from concurrent.futures import ThreadPoolExecutor from common.decorator_wrap import DecoratorWrap @@ -13,4 +14,14 @@ class ThreadPool(): self.__thread_obj = ThreadPoolExecutor(self.__max_threads) # Store the created thread self.__generate_list = [] - \ No newline at end of file + + def threaded_pool(self, func): + ''' + Externally callable thread pool decorator + ''' + @functools.wraps(func) + def inner(*args, **kwargs): + obj = self.__thread_obj.submit(func, *args) + self.__generate_list.append(obj) + return inner + \ No newline at end of file