Skip to content

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]

fix: reset _shared_session_lock in all tests for event loop isolation

d 🔹9e09bbc1dfbc
diff --git a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py b/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
index b71a61d2c29..763744609e3 100644
--- a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
+++ b/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
@@ -33,9 +33,13 @@ async def test_add_shared_session_attaches_open_session():
@pytest.mark.asyncio
async def test_add_shared_session_recreates_closed_session():
"""When the shared session is closed, it should be recreated."""
+ import litellm.proxy.route_llm_request as route_module
from litellm.proxy import proxy_server as proxy_server_module
from litellm.proxy.route_llm_request import add_shared_session_to_data
+ # Reset the module-level lock so each test uses the current event loop
+ route_module._shared_session_lock = None
+
closed_session = MagicMock()
closed_session.closed = True
@@ -64,9 +68,13 @@ async def test_add_shared_session_recreates_closed_session():
@pytest.mark.asyncio
async def test_add_shared_session_handles_recreation_failure():
"""When recreation fails, data should not contain shared_session."""
+ import litellm.proxy.route_llm_request as route_module
from litellm.proxy import proxy_server as proxy_server_module
from litellm.proxy.route_llm_request import add_shared_session_to_data
+ # Reset the module-level lock so each test uses the current event loop
+ route_module._shared_session_lock = None
+
closed_session = MagicMock()
closed_session.closed = True