Skip to content

Commit efd0ffd

Browse files
committed
fix test
1 parent fe49931 commit efd0ffd

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

tests/shared/test_session.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ async def test_request_cancellation():
5151
ev_tool_called = anyio.Event()
5252
ev_cancelled = anyio.Event()
5353
ev_cancel_notified = anyio.Event()
54-
request_id = None
5554

5655
# Start the request in a separate task so we can cancel it
5756
def make_server() -> Server:
@@ -60,9 +59,8 @@ def make_server() -> Server:
6059
# Register the tool handler
6160
@server.call_tool()
6261
async def handle_call_tool(name: str, arguments: dict | None) -> list:
63-
nonlocal request_id, ev_tool_called
62+
nonlocal ev_tool_called
6463
if name == "slow_tool":
65-
request_id = server.request_context.request_id
6664
ev_tool_called.set()
6765
await anyio.sleep(10) # Long enough to ensure we can cancel
6866
return []
@@ -116,16 +114,7 @@ async def make_request(client_session):
116114
with anyio.fail_after(1): # Timeout after 1 second
117115
await ev_tool_called.wait()
118116

119-
# Send cancellation notification
120-
assert request_id is not None
121-
await client_session.send_notification(
122-
ClientNotification(
123-
CancelledNotification(
124-
method="notifications/cancelled",
125-
params=CancelledNotificationParams(requestId=request_id),
126-
)
127-
)
128-
)
117+
tg.cancel_scope.cancel()
129118

130119
with anyio.fail_after(1):
131120
await ev_cancel_notified.wait()

0 commit comments

Comments
 (0)