Skip to content

feat(core): own startup, shutdown, and cancellation #3160

Open
0 of 1 issue completed
Open

Description

@ananthsub

Priority

Wave 1 — local lifecycle correctness. Live progress presentation is a separate #2831/#2859 workstream.

Problem

Local startup and shutdown do not share one bounded ownership boundary. Readiness can wait indefinitely, startup failure can bypass cleanup, shutdown uses per-process waits without one total deadline, and cancellation may be converted into an HTTP 500.

Essential scope

  • Transactional RunHelper acquisition: record each resource immediately and unwind everything acquired before startup failure.
  • Finite overall deadlines for head readiness, component readiness, configured endpoint readiness, cancellation cleanup, and shutdown.
  • Idempotent shutdown.
  • Start commands in process groups or another explicit descendant-ownership mechanism.
  • Signal, wait, escalate, reap, and continue cleaning other components within one total shutdown budget.
  • Re-raise CancelledError, KeyboardInterrupt, and SystemExit after bounded cleanup rather than converting them to ordinary HTTP failures.
  • Report unresolved remote cleanup when feat(core): define resources-session identity and close protocol #2609/feat(resources): add session TTL and lifecycle adoption #3037 data exists without claiming local process exit released it.

Moved or deferred scope

Dependencies

No hard dependency for local correctness. #144 depends on the durable process ownership and shutdown API established here. #2859 later consumes stable progress and identity APIs without blocking this issue.

Acceptance criteria

  • Fault injection after each startup stage releases every earlier acquisition.
  • Every readiness stage has one finite overall deadline and identifies the failed component.
  • Shutdown is idempotent and terminates owned descendants within one configured deadline.
  • Cancellation propagates after bounded cleanup and is not converted to HTTP 500.
  • Cleanup continues when one owned component does not exit.
  • Remote cleanup remains a separately reported state when available.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. changed the title [-]feat(core): own startup, shutdown, cancellation, and stall detection[/-] [+]feat(core): own startup, shutdown, and cancellation[/+] on Sep 10, 2026
  2. cwing-nvidia commented on Nov 29, 2026

    @cwing-nvidia
    Contributor

    One case to include in this issue's scope: the servers keep running when the gym process that started them ends without running its shutdown path.

    Reproduced at 66a0698 on macOS (Apple Silicon) and Ubuntu (x86-64), Python 3.13.14:

    1. gym env start --resources-server mcqa --model-type openai_model, wait for "All 4 / 4 servers ready".
    2. Send a signal to the gym process.
    3. List the server processes 12 to 15 seconds later.
    Signal to the gym process Server processes left
    SIGTERM none
    SIGHUP all 4, each with its shell wrapper, parent process 1
    SIGKILL all 4, each with its shell wrapper, parent process 1

    The result was the same on both systems, and nothing was printed in the two failing cases. The servers kept their ports until each process group was ended by hand.

    Where this comes up:

    • A terminal or SSH session that closes sends SIGHUP.
    • A script or coding agent that starts the command in the background from a non-interactive shell cannot stop it with SIGINT, because such a shell starts background jobs with SIGINT ignored. SIGTERM works. Agents often fall back to SIGKILL.
    • The out-of-memory killer and a scheduler's final kill after its grace period both send SIGKILL.

    The scope above covers shutdown that the gym process runs itself. In these cases it never runs, so a deadline or an idempotent shutdown does not help: the servers would need to notice that their parent is gone, or a later command would need to find and report them.

    A possible acceptance criterion: after SIGHUP or SIGKILL of the process that started the servers, no owned server process is still running once the shutdown deadline has passed.

    Each server is started in its own session (start_new_session=True in nemo_gym/server_runtime/supervisor/server_supervisor.py), and I found no code that ends a server when its parent exits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions