stdio_client logs "Process group termination failed ... Operation not permitted" on macOS when terminating a busy child
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- macos, python
- Área
- backend, operating-systems
Línea de trabajo
Empieza en mcp/os/posix/utilities.py e inspecciona la comprobación de actividad os.killpg(pgid, 0) después de enviar SIGTERM. Reproduce el problema cerrando stdio_client mientras su proceso hijo está bloqueado, usando el script descrito en el issue. El trabajo está hecho cuando una terminación correcta ya no emita la advertencia engañosa si la comprobación recibe PermissionError.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
On macOS, closing stdio_client for a child that has to be signalled
(it isn't exiting on stdin EOF) often logs a misleading warning, even
though termination succeeds.
Environment
mcp 1.30.0, Python 3.13, macOS (Darwin 27.2.0, arm64). Not tested on
Linux.
Reproduction
- Open
stdio_clientto a FastMCP stdio server. - Start a tool call that blocks the child, for example a synchronous
time.sleep(600). - Leave the
stdio_clientcontext. - Repeat 10 times.
The script is below.
Expected
No warning when the child is terminated successfully.
Actual
In 4 to 10 of 10 iterations, depending on timing:
WARNING mcp.os.posix.utilities: Process group termination failed for PID 4121: [Errno 1] Operation not permitted, falling back to simple terminate
The fallback process.terminate() succeeds, so nothing breaks, but the
warning is noisy and misleading. It does not occur when the child exits
by itself on stdin EOF, only when SIGTERM is needed.
Likely cause
In mcp/os/posix/utilities.py, after os.killpg(pgid, SIGTERM) the
code polls os.killpg(pgid, 0). Once the child has died but has not
been reaped (a zombie that is the only member of its group), macOS
returns EPERM instead of ESRCH, so the poll raises PermissionError
and the code takes the fallback path.
Treating PermissionError from that liveness poll as "group is gone"
would avoid the warning.
repro_sdk.py (usage: python repro_sdk.py <checkout-with-.venv> 10 hang)
"""usage: repro_sdk.py <project_dir> [iterations] [hang]
Uses only the MCP SDK (mcp 1.30.0): open a stdio_client to a trivial server, leave the context, count
'Process group termination failed' warnings. With `hang` the child is blocked (sync sleep) when closed."""
import asyncio, logging, os, sys, tempfile
logging.basicConfig(level=logging.WARNING, format="%(levelname)s %(name)s: %(message)s")
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
proj = sys.argv[1]; n = int(sys.argv[2]) if len(sys.argv) > 2 else 20; hang = "hang" in sys.argv
tmp = tempfile.mkdtemp()
open(tmp + "/child.py", "w").write(
"import time\nfrom mcp.server.fastmcp import FastMCP\nm = FastMCP('c')\[email protected]()\ndef hang() -> str:\n time.sleep(600)\n return 'x'\[email protected]()\ndef ok() -> str:\n return 'ok'\nm.run('stdio')\n")
async def one():
params = StdioServerParameters(command=proj + "/.venv/bin/python", args=[tmp + "/child.py"])
async with stdio_client(params) as (r, w):
async with ClientSession(r, w) as s:
await s.initialize()
if hang:
asyncio.create_task(s.call_tool("hang", {}))
await asyncio.sleep(0.5)
else:
await s.call_tool("ok", {})
for i in range(n):
asyncio.run(one())
print("done", n, "iterations")
- Lenguaje dominante
- Python
- Estrellas
- 25k
- Forks
- 4.2k
- Merge medio
- 10 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/python-sdk
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3978 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Client serves cached tools after its context exits with an exceptionPosiblemente ocupada @jonxsong la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
modelcontextprotocol/python-sdk#3968 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
modelcontextprotocol/python-sdk#3957 ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
modelcontextprotocol/python-sdk#3934 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
DCR `RegistrationHandler` accepts `{"redirect_uris": null}` and returns `201 Created` for `authorization_code` clientsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug v1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/python-sdk#3885 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/python-sdk
Issues similares
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePosiblemente ocupada @abdulwaarith0 la tomó hoy. Abiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
MakazhanAlpamys/Soup#3690 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug data-types native-format
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
ClickHouse/clickhouse-connect#1320 ·
Los mantenedores suelen responder en 1 día
-
Public benchmark import end-to-end test fails when the test stack's worker runs the parity jobAbiertoaccepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
future-agi/future-agi#6392 ·
Los mantenedores suelen responder en 1 día