From 7611807e22a952dcc44e3dd28cc318fb16b6b02e Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Sun, 25 May 2025 19:37:04 +0100 Subject: [PATCH] Threadpool should be used if GIL is disabled. --- libcst/codemod/_cli.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libcst/codemod/_cli.py b/libcst/codemod/_cli.py index 178cabcb8..0cdec1037 100644 --- a/libcst/codemod/_cli.py +++ b/libcst/codemod/_cli.py @@ -631,11 +631,7 @@ def parallel_exec_transform_with_prettyprint( # noqa: C901 # Let's just use a dummy synchronous executor. jobs = 1 pool_impl = DummyExecutor - elif getattr(sys, "_is_gil_enabled", lambda: False)(): # pyre-ignore[16] - from concurrent.futures import ThreadPoolExecutor - - pool_impl = functools.partial(ThreadPoolExecutor, max_workers=jobs) - else: + elif getattr(sys, "_is_gil_enabled", lambda: True)(): # pyre-ignore[16] from concurrent.futures import ProcessPoolExecutor pool_impl = functools.partial(ProcessPoolExecutor, max_workers=jobs) @@ -648,6 +644,10 @@ def parallel_exec_transform_with_prettyprint( # noqa: C901 else PartialParserConfig() ), ) + else: + from concurrent.futures import ThreadPoolExecutor + + pool_impl = functools.partial(ThreadPoolExecutor, max_workers=jobs) successes: int = 0 failures: int = 0