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:
+20
-5
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user