use threadpool as executor

This commit is contained in:
Matthieu Jolimaitre 2024-11-07 11:06:45 +01:00
parent 2cd073150e
commit c85cdc91ca

View file

@ -1,6 +1,6 @@
from dataclasses import dataclass
from multiprocessing.pool import ThreadPool
from typing import Callable, TypeVar
from multiprocessing import Pool
T = TypeVar("T")
@ -17,7 +17,7 @@ class RunStrategy:
class Parallel(RunStrategy):
procs: None | int = None
def run_all(self, items: list[T], oper: Callable[[T], O]) -> list[O]:
return Pool(self.procs).map(oper, items)
return ThreadPool(self.procs).map(oper, items)
class Sequential(RunStrategy):