Skip to content

Commit 38d6713

Browse files
committed
fix lowest version
1 parent c24d59e commit 38d6713

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/shared/test_streamable_http.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ async def replay_events_after(
124124
class ServerTest(Server):
125125
def __init__(self):
126126
super().__init__(SERVER_NAME)
127-
self._lock = anyio.Event()
128-
# Reset the lock for each new server instance
129-
self._lock.set()
130-
self._lock = anyio.Event()
127+
self._lock = None # Will be initialized in async context
131128

132129
@self.read_resource()
133130
async def handle_read_resource(uri: AnyUrl) -> str | bytes:
@@ -229,6 +226,10 @@ async def handle_call_tool(name: str, args: dict) -> list[TextContent]:
229226
]
230227

231228
elif name == "wait_for_lock_with_notification":
229+
# Initialize lock if not already done
230+
if self._lock is None:
231+
self._lock = anyio.Event()
232+
232233
# First send a notification
233234
await ctx.session.send_log_message(
234235
level="info",
@@ -251,6 +252,8 @@ async def handle_call_tool(name: str, args: dict) -> list[TextContent]:
251252
return [TextContent(type="text", text="Completed")]
252253

253254
elif name == "release_lock":
255+
assert self._lock is not None, "Lock must be initialized before releasing"
256+
254257
# Release the lock
255258
self._lock.set()
256259
return [TextContent(type="text", text="Lock released")]

0 commit comments

Comments
 (0)