The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
address P2 feedback: add lock docstring warning, remove redundant mock write
d 🔹ef22144854f0
diff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.pyindex 96e6f705cca..79e8f41972f 100644--- a/litellm/proxy/route_llm_request.py+++ b/litellm/proxy/route_llm_request.py@@ -128,7 +128,12 @@ _shared_session_lock: Optional[asyncio.Lock] = Nonedef _get_shared_session_lock() -> asyncio.Lock:- """Lazily create the shared session lock (must be called within a running event loop)."""+ """Lazily create the shared session lock (must be called within a running event loop).++ WARNING: Do not reset _shared_session_lock to None while any coroutine may be+ executing the session-recovery path; doing so breaks the double-checked locking+ guarantee and can cause duplicate session creation.+ """global _shared_session_lockif _shared_session_lock is None:_shared_session_lock = asyncio.Lock()diff --git a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py b/tests/test_litellm/proxy/test_aiohttp_session_recovery.pyindex 224a4aa1392..a2b09527962 100644--- a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py+++ b/tests/test_litellm/proxy/test_aiohttp_session_recovery.py@@ -161,7 +161,6 @@ async def test_add_shared_session_concurrent_recreation_uses_lock():call_count += 1# Simulate some async workawait asyncio.sleep(0.01)- proxy_server_module.shared_aiohttp_session = new_sessionreturn new_sessionwith patch.object(