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]

style: apply black formatting to fix CI lint check

voidborne-dca8f5cffa005
diff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.py
index 79e8f41972f..f1590b16c24 100644
--- a/litellm/proxy/route_llm_request.py
+++ b/litellm/proxy/route_llm_request.py
@@ -185,7 +185,9 @@ async def add_shared_session_to_data(data: dict) -> None:
"SESSION REUSE: Shared aiohttp session is None after re-check, recreating..."
)
try:
- new_session = await proxy_server._initialize_shared_aiohttp_session()
+ new_session = (
+ await proxy_server._initialize_shared_aiohttp_session()
+ )
except Exception:
verbose_proxy_logger.exception(
"SESSION REUSE: Exception during shared session recreation"
diff --git a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py b/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
index a2b09527962..f089d10425c 100644
--- a/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
+++ b/tests/test_litellm/proxy/test_aiohttp_session_recovery.py
@@ -22,9 +22,7 @@ async def test_add_shared_session_attaches_open_session():
mock_session = MagicMock()
mock_session.closed = False
- with patch(
- "litellm.proxy.proxy_server.shared_aiohttp_session", mock_session
- ):
+ with patch("litellm.proxy.proxy_server.shared_aiohttp_session", mock_session):
data = {}
await add_shared_session_to_data(data)
assert data["shared_session"] is mock_session
@@ -129,9 +127,7 @@ async def test_add_shared_session_no_session_available():
"""When no session was ever created, data should not contain shared_session."""
from litellm.proxy.route_llm_request import add_shared_session_to_data
- with patch(
- "litellm.proxy.proxy_server.shared_aiohttp_session", None
- ):
+ with patch("litellm.proxy.proxy_server.shared_aiohttp_session", None):
data = {}
await add_shared_session_to_data(data)
assert "shared_session" not in data
@@ -175,9 +171,7 @@ async def test_add_shared_session_concurrent_recreation_uses_lock():
):
# Launch 5 concurrent calls
results = [{} for _ in range(5)]
- await asyncio.gather(
- *(add_shared_session_to_data(d) for d in results)
- )
+ await asyncio.gather(*(add_shared_session_to_data(d) for d in results))
# Only 1 coroutine should have called _initialize (the rest see the
# re-checked session as open under the lock)