instead of waiting for all futures to end in each iteration, go to next iteration and don't start another of a still running one

This commit is contained in:
2021-02-06 19:02:55 +00:00
parent 6d1a06f7f9
commit 894e97d1ca
+20 -5
View File
@@ -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)