Skip to content

fix(cloudxr): start runtime with spawn context - #263

Open
WilliamK112 wants to merge 1 commit into
NVIDIA:mainfrom
WilliamK112:codex/avoid-runtime-fork
Open

fix(cloudxr): start runtime with spawn context#263
WilliamK112 wants to merge 1 commit into
NVIDIA:mainfrom
WilliamK112:codex/avoid-runtime-fork

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • start the native CloudXR runtime process from a spawn multiprocessing context instead of the platform-default fork context
  • keep the existing multiprocessing.Process handle shape so readiness polling and terminate_or_kill_runtime cleanup continue to work unchanged
  • add a focused unit test that stubs the native CloudXR imports and verifies the spawn context is requested

Rationale

Issue #40 calls out that the current multiprocessing.Process(target=runtime_run) path can fork from inside an already-running asyncio launcher. Using spawn starts the runtime in a fresh interpreter, avoiding inherited asyncio lock/signal-handler state, while keeping this patch small and avoiding a broader subprocess-handle refactor.

Fixes #40

Validation

  • Rebased onto current NVIDIA/xr-ai@ec4169aa3e3c8a57f1d7f59d3e2d97ad9163a8bb
  • uv run pytest -v test_cloudxr_runtime_process.py (from tests/) - 1 passed
  • uv run pytest -v test_cloudxr_runtime_process.py test_launcher_cloudxr_env.py (from tests/) - 24 passed
  • uv run python -m py_compile ..\cloudxr-runtime\cloudxr_runtime\__main__.py test_cloudxr_runtime_process.py (from tests/)
  • uv tool run --from ruff==0.15.16 ruff check cloudxr-runtime\cloudxr_runtime\__main__.py tests\test_cloudxr_runtime_process.py
  • git diff --check origin/main..HEAD

Signed-off-by: WilliamK112 <164879897+WilliamK112@users.noreply.github.com>
@WilliamK112
WilliamK112 force-pushed the codex/avoid-runtime-fork branch from 919a3a6 to 0004716 Compare July 2, 2026 02:46
@WilliamK112
WilliamK112 marked this pull request as ready for review July 2, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use asyncio.create_subprocess_exec is better to avoid forking

1 participant