Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
9e4d18c
1
Parent(s): 0f3d0c4
Reset session after closing
Browse files
src/fastmcp/client/client.py
CHANGED
|
@@ -268,6 +268,8 @@ class Client(Generic[ClientTransportT]):
|
|
| 268 |
|
| 269 |
async def close(self):
|
| 270 |
await self.transport.close()
|
|
|
|
|
|
|
| 271 |
|
| 272 |
# --- MCP Client Methods ---
|
| 273 |
|
|
|
|
| 268 |
|
| 269 |
async def close(self):
|
| 270 |
await self.transport.close()
|
| 271 |
+
self._session = None
|
| 272 |
+
self._initialize_result = None
|
| 273 |
|
| 274 |
# --- MCP Client Methods ---
|
| 275 |
|
tests/client/test_stdio.py
CHANGED
|
@@ -121,9 +121,7 @@ class TestKeepAlive:
|
|
| 121 |
client = Client(transport=PythonStdioTransport(script_path=stdio_script))
|
| 122 |
assert client.transport.keep_alive is True
|
| 123 |
|
| 124 |
-
with
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
async with client:
|
| 128 |
-
await client.close()
|
| 129 |
await client.call_tool("pid")
|
|
|
|
| 121 |
client = Client(transport=PythonStdioTransport(script_path=stdio_script))
|
| 122 |
assert client.transport.keep_alive is True
|
| 123 |
|
| 124 |
+
async with client:
|
| 125 |
+
await client.close()
|
| 126 |
+
with pytest.raises(RuntimeError, match="Client is not connected"):
|
|
|
|
|
|
|
| 127 |
await client.call_tool("pid")
|