Subprocess Sandboxing with Strict Resource Limits
Guards against runaway loops, excessive allocations, and hung threads
Spawns isolated child processes with enforced execution timeouts and signal handling (SIGTERM/SIGKILL), isolating host memory.
Safely execute Python code in isolated subprocesses with real-time streaming output and contextual AI error analysis.
PyFlow is an open source developer tool crafted by Alex Santos. It provides an isolated local execution runtime for Python code, accompanied by contextual AI explanations for tracebacks and interactive debugging chat.
Isolated subprocess execution with memory/timeout boundaries and streaming stdout/stderr capture.
Design choices, architectural patterns, and engineering decisions implemented for extreme reliability and developer experience.
Spawns isolated child processes with enforced execution timeouts and signal handling (SIGTERM/SIGKILL), isolating host memory.
When an exception occurs, PyFlow sends the traceback, relevant variables, and code chunk to an LLM to deliver clean, concise explanations.
Streams stdout and stderr directly to connected clients in real time, delivering an interactive REPL-like experience.
Switch between cloud providers or fully local Ollama models with a single environment variable change.
Real-world usage, terminal configuration, and technical integration commands.
from fastapi import FastAPI
from pydantic import BaseModel
import subprocess
app = FastAPI(title="PyFlow API")
class CodeExecutionRequest(BaseModel):
code: str
timeout_seconds: int = 10
@app.post("/api/execute")
async def execute_code(req: CodeExecutionRequest):
# Runs in isolated subprocess with timeout
result = subprocess.run(
["python", "-c", req.code],
capture_output=True,
text=True,
timeout=req.timeout_seconds
)
return {
"stdout": result.stdout,
"stderr": result.stderr,
"exit_code": result.returncode
}
Key clarifications regarding licensing, compatibility, deployment, and security.
Yes, it runs against the active Python virtual environment (venv).
Execution timeouts, subprocess isolation, and optional containerization via Docker.
Yes, PyFlow exposes standard OpenAPI/Swagger REST endpoints and SSE streams.
Yes, scripts requiring PyTorch or CUDA have direct access to available GPUs.