Skip to content

sandbox: Align create_process(stdout=None) to stdlib - #345

Open
scotttrinh wants to merge 4 commits into
mainfrom
sandbox-align-create-process
Open

sandbox: Align create_process(stdout=None) to stdlib#345
scotttrinh wants to merge 4 commits into
mainfrom
sandbox-align-create-process

Conversation

@scotttrinh

Copy link
Copy Markdown
Collaborator

Match Popen and run_process by inheriting output by default. Accept text streams so callers can stream directly without manually consuming readers. Drain the log transport before reporting completion so inherited streams receive all output and PIPE readers reach EOF reliably.

Match Popen and run_process by inheriting output by default. Accept text
streams so callers can stream directly without manually consuming
readers. Drain the log transport before reporting completion so
inherited streams receive all output and PIPE readers reach EOF
reliably.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates vercel-sandbox process output handling to align create_process() with subprocess.Popen semantics: stdout/stderr are inherited by default, callers can pass writable text streams directly, and process completion now drains the log transport to ensure output delivery and reliable EOF for PIPE readers.

Changes:

  • Default create_process(stdout=None, stderr=None) now inherits local stdout/stderr unless explicitly set to PIPE/DEVNULL/STDOUT.
  • Extend output routing to support writable TextIO destinations in addition to subprocess sentinels.
  • Add log-transport draining behavior before reporting process completion; update tests + add an example + news fragment.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/vercel-sandbox/vercel/sandbox/_internal/text_reader.py Adds TextIO destinations, transport draining, and inherited-output routing in the log reader core.
src/vercel-sandbox/vercel/sandbox/_internal/async_runtime.py Switches process handles to retain a transport and drains output in wait()/communicate(); changes create_process defaults to inherited output.
src/vercel-sandbox/vercel/sandbox/_internal/sync_runtime.py Sync equivalent of async runtime changes (transport retention + drain + inherited defaults).
src/vercel-sandbox/vercel/sandbox/_internal/process_output.py Updates live-stream destination validation to accept `TextIO
src/vercel-sandbox/tests/test_sandbox_text_reader.py Adds regression tests ensuring closing one reader doesn’t break non-buffer destinations; updates imports.
src/vercel-sandbox/tests/test_sandbox_public_flow.py Adjusts test to explicitly request PIPE now that defaults inherit output.
src/vercel-sandbox/tests/test_sandbox_process.py Adds tests for inherited-default behavior and updates existing tests to request PIPE explicitly.
src/vercel-sandbox/examples/sandbox_08_create_process.py New example demonstrating inherited vs captured output.
changes/vercel-sandbox/create-process-output.feature.md News fragment documenting the behavioral change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vercel-sandbox/vercel/sandbox/_internal/process_output.py
Comment thread src/vercel-sandbox/vercel/sandbox/_internal/text_reader.py
Comment on lines +117 to +121
@@ -118,7 +118,7 @@ class Process(_ProcessHandleState):
``subprocess.DEVNULL`` or merged with ``subprocess.STDOUT``.
"""

__slots__ = ("_service", "stderr", "stdout")
__slots__ = ("_service", "_transport", "stderr", "stdout")
Comment on lines +120 to +124
@@ -118,7 +121,7 @@ class SyncProcess(_ProcessHandleState):
``subprocess.DEVNULL`` or merged with ``subprocess.STDOUT``.
"""

__slots__ = ("_service", "stderr", "stdout")
__slots__ = ("_service", "_transport", "stderr", "stdout")
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.

2 participants