[Core][runtime_env] Avoid zombie subprocesses in check_output_cmd - #65611
Open
d3c3mber wants to merge 3 commits into
Open
[Core][runtime_env] Avoid zombie subprocesses in check_output_cmd#65611d3c3mber wants to merge 3 commits into
d3c3mber wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses a zombie process leak in check_output_cmd by wrapping the process wait call in asyncio.shield and asyncio.wait_for during cleanup, and adds corresponding unit tests. The review feedback suggests two important improvements: first, ensuring that any caught asyncio.CancelledError is re-raised to prevent swallowing task cancellation; second, checking the specific spawned process PID in the zombie test instead of using a wildcard os.waitpid(-1, ...) to avoid flakiness in concurrent test environments.
When PipPlugin.delete_uri cancels the outer task, the pending CancelledError caused 'await proc.wait()' to return immediately without reaping the child, leaving a <defunct> process that got re-parented to init. Wrap the wait in asyncio.shield + a bounded timeout, and fall back to transport.close() so the asyncio child watcher can reap the child in the background. Signed-off-by: botanggl <d3c3mber@users.noreply.github.com>
d3c3mber
force-pushed
the
fix/runtime-env-zombie-subprocess
branch
from
August 20, 2026 07:25
7927d50 to
1cd664d
Compare
Signed-off-by: botanggl <d3c3mber@users.noreply.github.com>
d3c3mber
force-pushed
the
fix/runtime-env-zombie-subprocess
branch
from
August 20, 2026 07:42
2cde793 to
f26f1f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When PipPlugin.delete_uri cancels the outer task, the pending CancelledError caused 'await proc.wait()' to return immediately without reaping the child, leaving a process that got re-parented to init.
Wrap the wait in asyncio.shield + a bounded timeout, and fall back to transport.close() so the asyncio child watcher can reap the child in the background.
Description
Related issues
Additional information