Skip to content

Commit 92f2dca

Browse files
Fix test_stdio_client_immediate_completion race condition
Use Python script instead of echo command to avoid BrokenResourceError on fast Linux systems where echo exits before streams are fully set up.
1 parent a27fcef commit 92f2dca

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/client/test_stdio.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,14 @@ async def test_stdio_client_immediate_completion():
150150
when processes exit normally and quickly.
151151
"""
152152

153-
# Use a command that exits immediately
154-
if sys.platform == "win32":
155-
server_params = StdioServerParameters(
156-
command="cmd",
157-
args=["/c", "echo", "hello"], # Windows: echo and exit
158-
)
159-
else:
160-
server_params = StdioServerParameters(
161-
command="echo",
162-
args=["hello"], # Unix: echo and exit
163-
)
153+
# Use a Python script that prints and exits immediately
154+
# This is more consistent across platforms than echo
155+
script_content = "print('hello')"
156+
157+
server_params = StdioServerParameters(
158+
command=sys.executable,
159+
args=["-c", script_content],
160+
)
164161

165162
start_time = time.time()
166163

0 commit comments

Comments
 (0)