File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed
Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change 1212async def test_messages_are_executed_concurrently ():
1313 server = FastMCP ("test" )
1414 event = anyio .Event ()
15- tool_started = anyio .Event ()
1615 call_order = []
1716
1817 @server .tool ("sleep" )
1918 async def sleep_tool ():
2019 call_order .append ("waiting_for_event" )
21- tool_started .set ()
2220 await event .wait ()
2321 call_order .append ("tool_end" )
2422 return "done"
2523
2624 @server .resource (_resource_name )
2725 async def slow_resource ():
28- # Wait for tool to start before setting the event
29- await tool_started .wait ()
26+ # Set event immediately
3027 event .set ()
3128 call_order .append ("resource_end" )
3229 return "slow"
3330
3431 async with create_session (server ._mcp_server ) as client_session :
35- # First tool will wait on event, second will set it
32+ # Start both requests concurrently
3633 async with anyio .create_task_group () as tg :
37- # Start the tool first (it will wait on event)
3834 tg .start_soon (client_session .call_tool , "sleep" )
39- # Then the resource (it will set the event)
4035 tg .start_soon (client_session .read_resource , AnyUrl (_resource_name ))
4136
4237 # Verify that both ran concurrently
You can’t perform that action at this time.
0 commit comments