Switched to Pooling and local aggregation

This commit is contained in:
Si11ium
2020-02-17 16:41:14 +01:00
parent 0b30e7c22c
commit db9f861d6c
7 changed files with 62 additions and 35 deletions

View File

@ -2,10 +2,12 @@ import multiprocessing as mp
import time
def run_n_in_parallel(f, n, **kwargs):
def run_n_in_parallel(f, n, processes=0, **kwargs):
processes = processes if processes else mp.cpu_count()
output = mp.Queue()
kwargs.update(output=output)
# Setup a list of processes that we want to run
processes = [mp.Process(target=f, kwargs=kwargs) for _ in range(n)]
# Run processes
results = []