Repository navigation
fix(sandbox): stop local subprocesses on cancellation - #3652
Conversation
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test f027228 |
|
@yuhezhang-ai The timeout-after-shell-exit case is covered in f027228. The test waits for shell exit before starting the timeout, checks the timeout result, and verifies that the child cannot write afterward. It fails against the older provider; all 13 local-provider tests and all-file pre-commit pass. CI has been requested for the updated head. Could you take another look? |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Reviewed the follow-up at f027228. The timeout-after-shell-exit regression addresses my optional suggestion and preserves the timeout result checks. Production code is unchanged from the completed review. All 13 local-provider tests pass locally, along with focused lint, formatting, and diff checks. No blocking code findings remain.
The full core/sandbox coverage and eight-shard server suite are still running; merge after those checks pass.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36903734298 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36904471129 |
Cancelling an in-flight local sandbox command previously left its subprocess group running, allowing background children to keep writing into the task workspace. Timeout cleanup also missed children when their shell had already exited, because looking up the departed shell's process-group ID failed.
Handle cancellation in the existing process-group kill and bounded reap block, then re-raise
CancelledError. Use the session leader PID directly as the process-group ID so cleanup still reaches children after shell exit. Preserve the timeout result contract and the bounded reap behavior introduced in #2863.The real-subprocess regression exercises the public
AsyncSandboxAPI for cancellation and timeout, each with a waiting shell and an exited shell. It waits for the child to start and the requested shell state before starting the provider's timeout, confirms the timeout result or propagated cancellation, then releases the child's pending write and verifies that it cannot write afterward.This is a focused lifecycle bug fix; no separate issue or API migration is needed.
Validation at
f027228bc5a55ecd2a6b2e923251df29455839aa:python -m pytest --import-mode=importlib tests/unit_tests/test_local_provider.py -o addopts='' -o log_cli=false -q— 13 passed.a6c5fb04f^, and passes with the final provider.pre-commit run --all-filesandgit diff --check— passed.