Skip to content

Commit 15f06a7

Browse files
committed
Do not start more threads than objects to compile
1 parent 0f6153a commit 15f06a7

File tree

1 file changed

+4
-3
lines changed
  • graalpython/com.oracle.graal.python.cext

1 file changed

+4
-3
lines changed

graalpython/com.oracle.graal.python.cext/setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ def _single_compile(obj):
164164
logger.debug("Compiling {!s}".format(src))
165165
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
166166

167-
if len(objects) > 1:
168-
logger.debug("Compiling {} objects in parallel.".format(len(objects)))
169-
pool = SimpleThreadPool()
167+
n_objects = len(objects)
168+
if n_objects > 1:
169+
logger.debug("Compiling {} objects in parallel.".format(n_objects))
170+
pool = SimpleThreadPool(min(n_objects, os.cpu_count()))
170171
pool.start_thread_pool(_single_compile)
171172
pool.put_job(objects)
172173
pool.wait_until_finished()

0 commit comments

Comments
 (0)