nemo_gym.sandbox.process_supervisor

View as Markdown

Standalone Linux process supervisor to upload beside a sandboxed harness.

Uses only the standard library; Gym need not be installed in the task sandbox. The receipt confirms descendant cleanup independently of the worker’s result.

Module Contents

Classes

NameDescription
CleanupReceiptOutcome written only after supervision and bounded cleanup finish.

Functions

NameDescription
_drain_childrenReap tool descendants, including processes that detached with setsid().
_positive_seconds-
_superviseEnforce a worker deadline, then acknowledge cleanup after all descendants exit.
exec_timeoutLeave room for TERM grace, worker reaping, descendant draining, and receipt I/O.
mainRun COMMAND and atomically write its cleanup receipt outside the task workdir.

Data

DEFAULT_CLEANUP_TIMEOUT

API

class nemo_gym.sandbox.process_supervisor.CleanupReceipt

Bases: typing.TypedDict

Outcome written only after supervision and bounded cleanup finish.

cleanup_confirmed
bool
error
str | None
return_code
int | None
timed_out
bool
nemo_gym.sandbox.process_supervisor._drain_children(
timeout: float
) -> None

Reap tool descendants, including processes that detached with setsid().

nemo_gym.sandbox.process_supervisor._positive_seconds(
value: str
) -> float
nemo_gym.sandbox.process_supervisor._supervise(
command: list[str],
timeout: float,
cleanup_timeout: float = DEFAULT_CLEANUP_TIMEOUT,
stop_path: pathlib.Path | None = None

Enforce a worker deadline, then acknowledge cleanup after all descendants exit.

nemo_gym.sandbox.process_supervisor.exec_timeout(
timeout: float,
cleanup_timeout: float = DEFAULT_CLEANUP_TIMEOUT
) -> float

Leave room for TERM grace, worker reaping, descendant draining, and receipt I/O.

nemo_gym.sandbox.process_supervisor.main() -> int

Run COMMAND and atomically write its cleanup receipt outside the task workdir.

nemo_gym.sandbox.process_supervisor.DEFAULT_CLEANUP_TIMEOUT = 10.0