We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7570ba3 commit c260e29Copy full SHA for c260e29
1 file changed
src/mcp/server/streamable_http_manager.py
@@ -4,7 +4,6 @@
4
5
import contextlib
6
import logging
7
-import threading
8
from collections.abc import AsyncIterator
9
from http import HTTPStatus
10
from typing import Any
@@ -75,7 +74,7 @@ def __init__(
75
74
# The task group will be set during lifespan
76
self._task_group = None
77
# Thread-safe tracking of run() calls
78
- self._run_lock = threading.Lock()
+ self._run_lock = anyio.Lock()
79
self._has_started = False
80
81
@contextlib.asynccontextmanager
@@ -97,7 +96,7 @@ async def lifespan(app: Starlette) -> AsyncIterator[None]:
97
96
yield
98
"""
99
# Thread-safe check to ensure run() is only called once
100
- with self._run_lock:
+ async with self._run_lock:
101
if self._has_started:
102
raise RuntimeError(
103
"StreamableHTTPSessionManager .run() can only be called "
0 commit comments