Fix: Replace threading.Lock with anyio.Lock for Ray deployment compatibility (#1151)
This commit is contained in:
parent
7570ba30cf
commit
c260e29a92
1 changed files with 2 additions and 3 deletions
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import threading
|
|
||||||
from collections.abc import AsyncIterator
|
from collections.abc import AsyncIterator
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
@ -75,7 +74,7 @@ class StreamableHTTPSessionManager:
|
||||||
# The task group will be set during lifespan
|
# The task group will be set during lifespan
|
||||||
self._task_group = None
|
self._task_group = None
|
||||||
# Thread-safe tracking of run() calls
|
# Thread-safe tracking of run() calls
|
||||||
self._run_lock = threading.Lock()
|
self._run_lock = anyio.Lock()
|
||||||
self._has_started = False
|
self._has_started = False
|
||||||
|
|
||||||
@contextlib.asynccontextmanager
|
@contextlib.asynccontextmanager
|
||||||
|
|
@ -97,7 +96,7 @@ class StreamableHTTPSessionManager:
|
||||||
yield
|
yield
|
||||||
"""
|
"""
|
||||||
# Thread-safe check to ensure run() is only called once
|
# Thread-safe check to ensure run() is only called once
|
||||||
with self._run_lock:
|
async with self._run_lock:
|
||||||
if self._has_started:
|
if self._has_started:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"StreamableHTTPSessionManager .run() can only be called "
|
"StreamableHTTPSessionManager .run() can only be called "
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue