Skip to content

Commit 5d52162

Browse files
committed
Added exception catching around threaded pool
1 parent f0878d5 commit 5d52162

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ def _single_compile(obj):
1414
except KeyError: return
1515
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
1616
# convert to list, imap is evaluated on-demand
17-
list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects))
17+
try:
18+
pool = multiprocessing.pool.ThreadPool(N)
19+
list(pool.imap(_single_compile,objects))
20+
except KeyboardInterrupt:
21+
print "Caught KeyboardInterrupt, terminating workers"
22+
pool.terminate()
23+
pool.join()
1824
return objects
1925
import distutils.ccompiler
2026
distutils.ccompiler.CCompiler.compile=parallelCCompile

0 commit comments

Comments
 (0)