agentscope-ai / agentscope-ai/QwenPaw
Windows: python hangs in execute_shell_command due to inherited stdin pipe (missing stdin=DEVNULL)
- Vorherrschende Sprache
- Python
- Sterne
- 34.9k
- Forks
- 3.1k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 225
Beschreibung
# Windows: `execute_shell_command` python hangs on inherited stdin pipe
## Environment
- Windows 11 (build 26200.7462)
- QwenPaw Desktop backend (PyInstaller onefile, `qwenpaw-backend.exe`)
- Python 3.14.3 (also reproduced with Python 3.12)
## Symptom
Running any python interpreter through `execute_shell_command` hangs indefinitely:
```
C:\Python314\python.exe -c "print(1)" # HANGS
```
`python --version` returns quickly, but any command that performs a full
interpreter initialization (`-c`, `-S`, `-E`, scripts) hangs.
Same shell command typed manually in `cmd.exe` works instantly.
## Root cause
`QwenPaw` backend spawns `cmd.exe` (via `subprocess.Popen` in
`qwenpaw/agents/tools/shell.py`, and `asyncio.create_subprocess_exec` in
`sandbox/local_sandbox.py`) **without specifying `stdin`**. With `stdin=None`,
the child inherits the parent's stdin handle, which for the backend is a pipe.
`python.exe` then inherits that pipe as stdin and blocks during interpreter
initialization. Redirecting stdin to `nul` fixes it instantly:
```
C:\Python314\python.exe -c "print(1)" < nul # WORKS (instant)
```
## Fix (in working tree)
Add `stdin=subprocess.DEVNULL` (or `stdin=asyncio.subprocess.DEVNULL`) to all
subprocess spawn sites that don't need interactive stdin:
1. `src/qwenpaw/agents/tools/shell.py` — `_execute_subprocess_sync` (`subprocess.Popen`) — **DONE**
2. `src/qwenpaw/agents/tools/shell.py` — POSIX `asyncio.create_subprocess_exec` — **DONE**
3. `src/qwenpaw/sandbox/local_sandbox.py` — `asyncio.create_subprocess_exec` — **DONE**
Reserve `stdin=PIPE` only for processes that genuinely need interactive input.
## Repro
```
python -c "print(1)" # via execute_shell_command → hangs
python -c "print(1)" < nul # via execute_shell_command → prints 1
```
## Suggested change (patch)
```python
proc = subprocess.Popen(
wrapped,
shell=False,
stdin=subprocess.DEVNULL, # ← ADDED
stdout=stdout_file,
stderr=stderr_file,
...
)
```
---
Created by user (Serge) — issue candidate, 2026-08-26.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.