diff --git a/modman/main.py b/modman/main.py index 772fe93..236e51c 100755 --- a/modman/main.py +++ b/modman/main.py @@ -10,14 +10,29 @@ folder = "scripts" mm = ModuleManager(folder) mods = mm.modules -while True: - mm.update() - with ThreadPoolExecutor() as ex: - for f in mods.values(): + +futs = {} + +with ThreadPoolExecutor() as ex: + while True: + mm.update() + + for n, fut in tuple(futs.items()): + if fut.done(): + del futs[n] + + print("not done:", futs) + + for n, f in mods.items(): + if n in futs: + print(f"{n} still running... will not start again") + continue + fut = ex.submit(f) print(fut) + futs[n] = fut - sleep(1) + sleep(1)