stdio_client logs "Process group termination failed ... Operation not permitted" on macOS when terminating a busy child
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 79/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- macos, python
- Lĩnh vực
- backend, operating-systems
Hướng nghiên cứu
Bắt đầu tại mcp/os/posix/utilities.py và kiểm tra phép thăm dò trạng thái hoạt động os.killpg(pgid, 0) sau khi gửi SIGTERM. Tái hiện bằng cách đóng stdio_client khi tiến trình con của nó đang bị chặn, sử dụng tập lệnh được mô tả trong issue. Công việc hoàn tất khi việc kết thúc thành công không còn phát ra cảnh báo gây hiểu lầm nếu phép thăm dò nhận được PermissionError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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")
- Ngôn ngữ chính
- Python
- Star
- 25k
- Fork
- 4.2k
- Merge trung bình
- 10 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
modelcontextprotocol/python-sdk#3978 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Client serves cached tools after its context exits with an exceptionCó thể đã có người làm @jonxsong đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
modelcontextprotocol/python-sdk#3968 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/python-sdk#3957 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
modelcontextprotocol/python-sdk#3934 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DCR `RegistrationHandler` accepts `{"redirect_uris": null}` and returns `201 Created` for `authorization_code` clientsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/python-sdk#3885 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwiseCó thể đã có người làm @abdulwaarith0 đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
MakazhanAlpamys/Soup#3690 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug data-types native-format
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ClickHouse/clickhouse-connect#1320 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Public benchmark import end-to-end test fails when the test stack's worker runs the parity jobĐang mởaccepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
future-agi/future-agi#6392 ·
Maintainer thường phản hồi trong vòng 1 ngày