From a794a6f513d5b9f2a9e295f9481223d37a5e4d3e Mon Sep 17 00:00:00 2001 From: GalaxySnail Date: Thu, 10 Feb 2022 10:28:32 +0800 Subject: [PATCH] BUG: use ThreadPoolExecutor instead of ThreadPool Use `concurrent.futures.ThreadPoolExecutor` in distutils instead of `multiprocessing.pool.ThreadPool`. Fix #21026 --- numpy/distutils/ccompiler.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 16f00d8edf17..74e2c51f600c 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -355,10 +355,9 @@ def single_compile(args): if len(build) > 1 and jobs > 1: # build parallel - import multiprocessing.pool - pool = multiprocessing.pool.ThreadPool(jobs) - pool.map(single_compile, build_items) - pool.close() + from concurrent.futures import ThreadPoolExecutor + with ThreadPoolExecutor(jobs) as pool: + pool.map(single_compile, build_items) else: # build serial for o in build_items: