Start script when dependencies are satisfied
(script_config: ScriptConfig)
| 1098 | import threading |
| 1099 | |
| 1100 | def start_script_when_ready(script_config: ScriptConfig): |
| 1101 | """Start script when dependencies are satisfied""" |
| 1102 | script_path = script_config.path |
| 1103 | |
| 1104 | # Wait for dependent scripts to start |
| 1105 | while True: |
| 1106 | dependencies_satisfied = True |
| 1107 | for dep_path in script_config.depends_on: |
| 1108 | if dep_path not in started_scripts: |
| 1109 | dependencies_satisfied = False |
| 1110 | break |
| 1111 | |
| 1112 | if dependencies_satisfied: |
| 1113 | break |
| 1114 | |
| 1115 | # Wait briefly and then check again |
| 1116 | time.sleep(0.5) |
| 1117 | |
| 1118 | # Wait for delay time |
| 1119 | if script_config.delay_sec > 0: |
| 1120 | print(f"⏱️ Wait {script_config.delay_sec} seconds before starting: {script_path}") |
| 1121 | time.sleep(script_config.delay_sec) |
| 1122 | |
| 1123 | # Start script |
| 1124 | print(f"🚀 Start script: {script_path}") |
| 1125 | process_info = self.execute_script(script_config) |
| 1126 | results[script_path] = process_info |
| 1127 | |
| 1128 | # Mark as started (even if startup fails, mark it to avoid blocking other scripts) |
| 1129 | started_scripts.add(script_path) |
| 1130 | |
| 1131 | # Start monitor thread for each script |
| 1132 | threads = [] |
nothing calls this directly
no test coverage detected