from concurrent.futures import ThreadPoolExecutor
from typing import List
id_str = ['1', '2', '3', '4', '5']
id_int = [1, 2, 3, 4, 5]
tp = ThreadPoolExecutor(10)
def threaded(fn):
def wrapper(self,lst: List[int]):
return tp.map(fn,[self]*len(lst),lst)
return wrapper
class testit:
def __init__(self, some_list: List[str]) -> None:
self._ids = some_list
print(self._ids)
@threaded
def test_first(self,some_id: int) -> int:
return -some_id
class showit(testit):
def __init__(self, *args):
super(showit, self).__init__(*args)
def again(self):
global id_int
for values in self.test_first(id_int):
print(repr(values))
a = showit(id_str)
a.again()