"""Standalone script: connect to the running sim and call flomni.tomo_queue_execute(). Run as a real OS subprocess (its own main thread) rather than a Python thread inside the test process: BECIPythonClient 's live-update machinery installs a SIGINT handler per scan request, which Python only allows from a process's real main thread (see _queue_helpers.ProgressSampler for the same constraint hit from the thread side). Section B/C tests spawn this and SIGKILL it (or edit the queue concurrently from a second client) to simulate a crashed kernel / a second operator session. Usage: python _run_queue_subprocess.py [start_index] Exit code is 0 on a clean run, 1 if tomo_queue_execute() raised. """ import sys from _bootstrap import build_flomni, shutdown def main() -> int: services_config_path = sys.argv[1] start_index = int(sys.argv[2]) if len(sys.argv) > 2 else 0 bec, flomni = build_flomni(services_config_path) try: flomni.tomo_queue_execute(start_index=start_index) except Exception as exc: # noqa: BLE001 - reported via exit code, not re-raised print(f"_run_queue_subprocess: tomo_queue_execute() raised: {exc}", file=sys.stderr) return 1 finally: shutdown(bec) return 0 if __name__ == "__main__": sys.exit(main())