Skip to content

Commit 0b2cdb9

Browse files
committed
fix: reuse global executor
1 parent ed0d59c commit 0b2cdb9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

laygo/transformers/parallel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import overload
1818

1919
from loky import ProcessPoolExecutor
20+
from loky import get_reusable_executor
2021

2122
from laygo.errors import ErrorHandler
2223
from laygo.helpers import PipelineContext
@@ -119,6 +120,8 @@ def __call__(self, data: Iterable[In], context: PipelineContext | None = None) -
119120
def _execute_with_context(self, data: Iterable[In], shared_context: MutableMapping[str, Any]) -> Iterator[Out]:
120121
"""Helper to run the execution logic with a given context."""
121122
with ProcessPoolExecutor(max_workers=self.max_workers) as executor:
123+
executor = get_reusable_executor(max_workers=self.max_workers)
124+
122125
chunks_to_process = self._chunk_generator(data)
123126
gen_func = self._ordered_generator if self.ordered else self._unordered_generator
124127
processed_chunks_iterator = gen_func(chunks_to_process, executor, shared_context)

0 commit comments

Comments
 (0)