From d5ab52b95aba03359a6b8947e86a2009bcafec5b Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Fri, 7 Jun 2019 08:46:19 +0200 Subject: [PATCH] Enclose ThreadPool.map call in a try/finally block --- lib/spack/spack/compilers/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 919380f5f26..e7a7f1d5895 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -210,8 +210,10 @@ def find_compilers(*path_hints): # Here we map the function arguments to the corresponding calls tp = multiprocessing.pool.ThreadPool() - detected_versions = tp.map(detect_version, arguments) - tp.close() + try: + detected_versions = tp.map(detect_version, arguments) + finally: + tp.close() def valid_version(item): value, error = item