-
Notifications
You must be signed in to change notification settings - Fork 2k
#552 #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
#552 #707
Changes from all commits
9a797c2
1fba897
2f25562
0ec5bc0
289281b
7a84ecb
90f2cc1
8c6fc2a
bd6cc71
fb09415
8ba9b5e
947a37a
a5b53cf
e64a939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import asyncio | ||
import sys | ||
|
||
import pytest | ||
|
||
from mcp import ClientSession, StdioServerParameters | ||
from mcp.client.stdio import stdio_client | ||
|
||
# @pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific test") | ||
@pytest.mark.skipif(sys.version_info < (3, 11), reason="asyncio.timeout in 3.11+") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you switch to |
||
@pytest.mark.parametrize( | ||
"args", | ||
[ | ||
["/C", "echo", '{"jsonrpc": "2.0", "id": 1, "result": null}'], | ||
["dfghfgh"], | ||
["/C", "echo"], | ||
], | ||
) | ||
@pytest.mark.anyio | ||
async def test_windows_process_creation(args): | ||
""" | ||
Test that directly tests the process creation function that was fixed in issue #552. | ||
This simpler test verifies that Windows process creation works without hanging. | ||
""" | ||
# Use a simple command that should complete quickly on Windows | ||
params = StdioServerParameters( | ||
command="cmd", | ||
# Echo a valid JSON-RPC response message that will be parsed correctly | ||
args=args, | ||
) | ||
|
||
# Directly test the fixed function that was causing the hanging issue | ||
try: | ||
# Set a timeout to prevent hanging | ||
async with asyncio.timeout(5): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use |
||
# Test the actual process creation function that was fixed | ||
async with stdio_client(params) as (read, write): | ||
print("inside client") | ||
async with ClientSession(read, write) as c: | ||
print("inside ClientSession") | ||
await c.initialize() | ||
|
||
except asyncio.TimeoutError: | ||
pytest.xfail("Process creation timed out, indicating a hang issue") | ||
except ProcessLookupError: | ||
pytest.xfail("Process creation failed with ProcessLookupError") | ||
except Exception as e: | ||
assert "ExceptionGroup" in repr(e), f"Unexpected error: {e}" | ||
assert "ProcessLookupError" in repr(e), f"Unexpected error: {e}" | ||
pytest.xfail(f"Expected error: {e}") | ||
Comment on lines
+32
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you simplify to use
Then you don't need to do all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be uncommented? Tests do seem to fail on Ubuntu