from library.analysis import testSets, generators, runExercise
import os
import threading


nWorker = 0

for dataset in testSets:
    for (name, f) in generators:
        nWorker += 1
        if 0 == os.fork():
            print(f"#{nWorker}: start: {name}({dataset})")
            runExercise(dataset, None, name, f)
            print(f"#{nWorker}: end.")
            exit()
        else:
            if nWorker >= 2:
                os.wait()
                nWorker -= 1

while nWorker > 0:
    os.wait()
    nWorker -= 1

