-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
26 lines (19 loc) · 656 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import importlib
import importlib.util
import os
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
def run_app(app: str):
os.system(f"python {app}")
def main():
app_paths = [p for p in Path("./examples").rglob("*.py")]
with ProcessPoolExecutor() as executor:
for ap in app_paths:
spec = importlib.util.spec_from_file_location(f"{ap.stem}", ap)
app = importlib.util.module_from_spec(spec)
spec.loader.exec_module(app)
if app.RUN:
print("running app:", app)
executor.submit(run_app, ap)
if __name__ == "__main__":
main()