mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 13:34:17 +02:00
Reset session after closing
This commit is contained in:
parent
441223f98c
commit
975f151a9b
2 changed files with 5 additions and 5 deletions
|
|
@ -268,6 +268,8 @@ class Client(Generic[ClientTransportT]):
|
|||
|
||||
async def close(self):
|
||||
await self.transport.close()
|
||||
self._session = None
|
||||
self._initialize_result = None
|
||||
|
||||
# --- MCP Client Methods ---
|
||||
|
||||
|
|
|
|||
|
|
@ -121,9 +121,7 @@ class TestKeepAlive:
|
|||
client = Client(transport=PythonStdioTransport(script_path=stdio_script))
|
||||
assert client.transport.keep_alive is True
|
||||
|
||||
with pytest.raises(
|
||||
RuntimeError, match="Server session was closed unexpectedly"
|
||||
):
|
||||
async with client:
|
||||
await client.close()
|
||||
async with client:
|
||||
await client.close()
|
||||
with pytest.raises(RuntimeError, match="Client is not connected"):
|
||||
await client.call_tool("pid")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue