Skip to content

Commit

Permalink
Ensure ThreadPool is closed in setup_helpers
Browse files Browse the repository at this point in the history
The ParallelCompile setup helper using a ThreadPool to enable its
parallelism. It does not properly close the pool when it is done with
it.
This can lead to a "Exception ignored in: <function Pool.__del__..."
message with traceback being printed at shutdown.
  • Loading branch information
Bobby Impollonia committed Dec 12, 2021
1 parent 59aa998 commit 8643097
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pybind11/setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,9 @@ def _single_compile(obj):
threads = 1

if threads > 1:
for _ in ThreadPool(threads).imap_unordered(_single_compile, objects):
pass
with ThreadPool(threads) as pool:
for _ in pool.imap_unordered(_single_compile, objects):
pass
else:
for ob in objects:
_single_compile(ob)
Expand Down

0 comments on commit 8643097

Please sign in to comment.