Skip to content

Commit b560ae8

Browse files
authored
Threadpool should be used if GIL is disabled. (#1335)
1 parent c224665 commit b560ae8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

libcst/codemod/_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,11 +631,7 @@ def parallel_exec_transform_with_prettyprint( # noqa: C901
631631
# Let's just use a dummy synchronous executor.
632632
jobs = 1
633633
pool_impl = DummyExecutor
634-
elif getattr(sys, "_is_gil_enabled", lambda: False)(): # pyre-ignore[16]
635-
from concurrent.futures import ThreadPoolExecutor
636-
637-
pool_impl = functools.partial(ThreadPoolExecutor, max_workers=jobs)
638-
else:
634+
elif getattr(sys, "_is_gil_enabled", lambda: True)(): # pyre-ignore[16]
639635
from concurrent.futures import ProcessPoolExecutor
640636

641637
pool_impl = functools.partial(ProcessPoolExecutor, max_workers=jobs)
@@ -648,6 +644,10 @@ def parallel_exec_transform_with_prettyprint( # noqa: C901
648644
else PartialParserConfig()
649645
),
650646
)
647+
else:
648+
from concurrent.futures import ThreadPoolExecutor
649+
650+
pool_impl = functools.partial(ThreadPoolExecutor, max_workers=jobs)
651651

652652
successes: int = 0
653653
failures: int = 0

0 commit comments

Comments
 (0)