mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-01 17:37:43 +00:00
number of subprocesses <= number of tasks (#434)
This commit is contained in:
@@ -105,7 +105,7 @@ def multiprocessing_wrapper(func_calls: list[tuple[Callable, tuple]], n: int) ->
|
||||
"""
|
||||
if n == 1:
|
||||
return [f(*args) for f, args in func_calls]
|
||||
with mp.Pool(processes=n) as pool:
|
||||
with mp.Pool(processes=max(1, min(n, len(func_calls)))) as pool:
|
||||
results = [pool.apply_async(f, args) for f, args in func_calls]
|
||||
return [result.get() for result in results]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user