mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-24 09:14:21 +01:00
Close unclosed resources in the whole project (#267)
* Close resources * Close all resources * Update pyproject.toml * Close all resources * Close all resources * try now... * try to ignore this * try again * try adding one more.. * try now * try now * revert ci changes
This commit is contained in:
committed by
GitHub
parent
1691b905e2
commit
94d326dbf1
@@ -83,6 +83,10 @@ async def test_client_session_initialize():
|
||||
async with (
|
||||
ClientSession(server_to_client_receive, client_to_server_send) as session,
|
||||
anyio.create_task_group() as tg,
|
||||
client_to_server_send,
|
||||
client_to_server_receive,
|
||||
server_to_client_send,
|
||||
server_to_client_receive,
|
||||
):
|
||||
tg.start_soon(mock_server)
|
||||
tg.start_soon(listen_session)
|
||||
|
||||
@@ -43,7 +43,13 @@ async def test_request_id_match() -> None:
|
||||
)
|
||||
|
||||
# Start server task
|
||||
async with anyio.create_task_group() as tg:
|
||||
async with (
|
||||
anyio.create_task_group() as tg,
|
||||
client_writer,
|
||||
client_reader,
|
||||
server_writer,
|
||||
server_reader,
|
||||
):
|
||||
tg.start_soon(run_server)
|
||||
|
||||
# Send initialize request
|
||||
|
||||
@@ -25,7 +25,7 @@ async def test_lowlevel_server_lifespan():
|
||||
"""Test that lifespan works in low-level server."""
|
||||
|
||||
@asynccontextmanager
|
||||
async def test_lifespan(server: Server) -> AsyncIterator[dict]:
|
||||
async def test_lifespan(server: Server) -> AsyncIterator[dict[str, bool]]:
|
||||
"""Test lifespan context that tracks startup/shutdown."""
|
||||
context = {"started": False, "shutdown": False}
|
||||
try:
|
||||
@@ -50,7 +50,13 @@ async def test_lowlevel_server_lifespan():
|
||||
return [{"type": "text", "text": "true"}]
|
||||
|
||||
# Run server in background task
|
||||
async with anyio.create_task_group() as tg:
|
||||
async with (
|
||||
anyio.create_task_group() as tg,
|
||||
send_stream1,
|
||||
receive_stream1,
|
||||
send_stream2,
|
||||
receive_stream2,
|
||||
):
|
||||
|
||||
async def run_server():
|
||||
await server.run(
|
||||
@@ -147,7 +153,13 @@ async def test_fastmcp_server_lifespan():
|
||||
return True
|
||||
|
||||
# Run server in background task
|
||||
async with anyio.create_task_group() as tg:
|
||||
async with (
|
||||
anyio.create_task_group() as tg,
|
||||
send_stream1,
|
||||
receive_stream1,
|
||||
send_stream2,
|
||||
receive_stream2,
|
||||
):
|
||||
|
||||
async def run_server():
|
||||
await server._mcp_server.run(
|
||||
|
||||
Reference in New Issue
Block a user