use Executor
This commit is contained in:
@ -1,36 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from time import sleep
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from modman import ModuleManager
|
||||
from executing import Executor
|
||||
|
||||
|
||||
folder = "scripts"
|
||||
mm = ModuleManager(folder)
|
||||
mods = mm.modules
|
||||
|
||||
|
||||
futs = {}
|
||||
|
||||
with ThreadPoolExecutor() as ex:
|
||||
with Executor() as ex:
|
||||
while True:
|
||||
mm.update()
|
||||
|
||||
for n, fut in tuple(futs.items()):
|
||||
if fut.done():
|
||||
del futs[n]
|
||||
|
||||
print("not done:", futs)
|
||||
ex.cleanup()
|
||||
print("not done:", ex.futures)
|
||||
|
||||
for n, f in mods.items():
|
||||
if n in futs:
|
||||
if n in ex.futures:
|
||||
print(f"{n} still running... will not start again")
|
||||
continue
|
||||
|
||||
fut = ex.submit(f)
|
||||
print(fut)
|
||||
futs[n] = fut
|
||||
fut = ex.run(n, f)
|
||||
print(fut, "->", n)
|
||||
|
||||
sleep(1)
|
||||
|
||||
|
Reference in New Issue
Block a user