Skip to content

Commit 04acd4b

Browse files
committed
Update var name for consistency
1 parent 77a39e7 commit 04acd4b

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

litellm/llms/custom_httpx/http_handler.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __init__(
167167
concurrent_limit=1000,
168168
client_alias: Optional[str] = None, # name for client in logs
169169
ssl_verify: Optional[VerifyTypes] = None,
170-
existing_session: Optional["ClientSession"] = None,
170+
shared_session: Optional["ClientSession"] = None,
171171
):
172172
self.timeout = timeout
173173
self.event_hooks = event_hooks
@@ -176,7 +176,7 @@ def __init__(
176176
concurrent_limit=concurrent_limit,
177177
event_hooks=event_hooks,
178178
ssl_verify=ssl_verify,
179-
existing_session=existing_session,
179+
shared_session=shared_session,
180180
)
181181
self.client_alias = client_alias
182182

@@ -186,7 +186,7 @@ def create_client(
186186
concurrent_limit: int,
187187
event_hooks: Optional[Mapping[str, List[Callable[..., Any]]]],
188188
ssl_verify: Optional[VerifyTypes] = None,
189-
existing_session: Optional["ClientSession"] = None,
189+
shared_session: Optional["ClientSession"] = None,
190190
) -> httpx.AsyncClient:
191191
# Get unified SSL configuration
192192
ssl_config = get_ssl_configuration(ssl_verify)
@@ -202,7 +202,7 @@ def create_client(
202202
transport = AsyncHTTPHandler._create_async_transport(
203203
ssl_context=ssl_config if isinstance(ssl_config, ssl.SSLContext) else None,
204204
ssl_verify=ssl_config if isinstance(ssl_config, bool) else None,
205-
existing_session=existing_session,
205+
shared_session=shared_session,
206206
)
207207

208208
return httpx.AsyncClient(
@@ -528,7 +528,7 @@ def __del__(self) -> None:
528528
def _create_async_transport(
529529
ssl_context: Optional[ssl.SSLContext] = None,
530530
ssl_verify: Optional[bool] = None,
531-
existing_session: Optional["ClientSession"] = None,
531+
shared_session: Optional["ClientSession"] = None,
532532
) -> Optional[Union[LiteLLMAiohttpTransport, AsyncHTTPTransport]]:
533533
"""
534534
- Creates a transport for httpx.AsyncClient
@@ -551,7 +551,7 @@ def _create_async_transport(
551551
return AsyncHTTPHandler._create_aiohttp_transport(
552552
ssl_context=ssl_context,
553553
ssl_verify=ssl_verify,
554-
existing_session=existing_session,
554+
shared_session=shared_session,
555555
)
556556

557557
#########################################################
@@ -619,7 +619,7 @@ def _get_ssl_connector_kwargs(
619619
def _create_aiohttp_transport(
620620
ssl_verify: Optional[bool] = None,
621621
ssl_context: Optional[ssl.SSLContext] = None,
622-
existing_session: Optional["ClientSession"] = None,
622+
shared_session: Optional["ClientSession"] = None,
623623
) -> LiteLLMAiohttpTransport:
624624
"""
625625
Creates an AiohttpTransport with RequestNotRead error handling
@@ -644,12 +644,12 @@ def _create_aiohttp_transport(
644644

645645
verbose_logger.debug("Creating AiohttpTransport...")
646646

647-
# Use existing session if provided and valid
648-
if existing_session is not None and not existing_session.closed:
647+
# Use shared session if provided and valid
648+
if shared_session is not None and not shared_session.closed:
649649
verbose_logger.debug(
650-
f"SHARED SESSION: Reusing existing ClientSession (ID: {id(existing_session)})"
650+
f"SHARED SESSION: Reusing existing ClientSession (ID: {id(shared_session)})"
651651
)
652-
return LiteLLMAiohttpTransport(client=existing_session)
652+
return LiteLLMAiohttpTransport(client=shared_session)
653653

654654
# Create new session only if none provided or existing one is invalid
655655
verbose_logger.debug(
@@ -941,7 +941,7 @@ def _create_sync_transport(self) -> Optional[HTTPTransport]:
941941
def get_async_httpx_client(
942942
llm_provider: Union[LlmProviders, httpxSpecialProvider],
943943
params: Optional[dict] = None,
944-
existing_session: Optional["ClientSession"] = None,
944+
shared_session: Optional["ClientSession"] = None,
945945
) -> AsyncHTTPHandler:
946946
"""
947947
Retrieves the async HTTP client from the cache
@@ -963,12 +963,12 @@ def get_async_httpx_client(
963963
return _cached_client
964964

965965
if params is not None:
966-
params["existing_session"] = existing_session
966+
params["shared_session"] = shared_session
967967
_new_client = AsyncHTTPHandler(**params)
968968
else:
969969
_new_client = AsyncHTTPHandler(
970970
timeout=httpx.Timeout(timeout=600.0, connect=5.0),
971-
existing_session=existing_session,
971+
shared_session=shared_session,
972972
)
973973

974974
litellm.in_memory_llm_clients_cache.set_cache(

litellm/llms/custom_httpx/llm_http_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async def async_completion(
246246
async_httpx_client = get_async_httpx_client(
247247
llm_provider=litellm.LlmProviders(custom_llm_provider),
248248
params={"ssl_verify": litellm_params.get("ssl_verify", None)},
249-
existing_session=shared_session,
249+
shared_session=shared_session,
250250
)
251251
else:
252252
async_httpx_client = client

litellm/llms/openai/common_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _get_async_http_client(
214214
if isinstance(ssl_config, ssl.SSLContext)
215215
else None,
216216
ssl_verify=ssl_config if isinstance(ssl_config, bool) else None,
217-
existing_session=shared_session,
217+
shared_session=shared_session,
218218
),
219219
follow_redirects=True,
220220
)

tests/test_litellm/llms/custom_httpx/test_http_handler.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -192,38 +192,38 @@ def __init__(self):
192192
self.closed = False
193193

194194
@pytest.mark.asyncio
195-
async def test_create_aiohttp_transport_with_existing_session():
196-
"""Test that _create_aiohttp_transport reuses existing session when provided"""
195+
async def test_create_aiohttp_transport_with_shared_session():
196+
"""Test that _create_aiohttp_transport reuses shared session when provided"""
197197
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
198198

199-
# Create a mock existing session that's not callable
199+
# Create a mock shared session that's not callable
200200
mock_session = MockClientSession()
201201

202-
# Test with existing session
202+
# Test with shared session
203203
transport = AsyncHTTPHandler._create_aiohttp_transport(
204-
existing_session=mock_session # type: ignore
204+
shared_session=mock_session # type: ignore
205205
)
206206

207-
# Verify the transport uses the existing session directly
207+
# Verify the transport uses the shared session directly
208208
assert transport.client is mock_session
209209
assert not callable(transport.client) # Should not be callable
210210

211211

212212
@pytest.mark.asyncio
213-
async def test_create_aiohttp_transport_without_existing_session():
213+
async def test_create_aiohttp_transport_without_shared_session():
214214
"""Test that _create_aiohttp_transport creates new session when none provided"""
215215
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
216216

217-
# Test without existing session
218-
transport = AsyncHTTPHandler._create_aiohttp_transport(existing_session=None)
217+
# Test without shared session
218+
transport = AsyncHTTPHandler._create_aiohttp_transport(shared_session=None)
219219

220220
# Verify the transport uses a lambda function (for backward compatibility)
221221
assert callable(transport.client) # Should be a lambda function
222222

223223

224224
@pytest.mark.asyncio
225225
async def test_create_aiohttp_transport_with_closed_session():
226-
"""Test that _create_aiohttp_transport creates new session when existing session is closed"""
226+
"""Test that _create_aiohttp_transport creates new session when shared session is closed"""
227227
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
228228

229229
# Create a mock closed session
@@ -232,42 +232,42 @@ async def test_create_aiohttp_transport_with_closed_session():
232232

233233
# Test with closed session
234234
transport = AsyncHTTPHandler._create_aiohttp_transport(
235-
existing_session=mock_session # type: ignore
235+
shared_session=mock_session # type: ignore
236236
)
237237

238238
# Verify the transport creates a new session (lambda function)
239239
assert callable(transport.client) # Should be a lambda function
240240

241241

242242
@pytest.mark.asyncio
243-
async def test_async_handler_with_existing_session():
244-
"""Test AsyncHTTPHandler initialization with existing session"""
243+
async def test_async_handler_with_shared_session():
244+
"""Test AsyncHTTPHandler initialization with shared session"""
245245
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
246246

247-
# Create a mock existing session
247+
# Create a mock shared session
248248
mock_session = MockClientSession()
249249

250-
# Create handler with existing session
251-
handler = AsyncHTTPHandler(existing_session=mock_session) # type: ignore
250+
# Create handler with shared session
251+
handler = AsyncHTTPHandler(shared_session=mock_session) # type: ignore
252252

253253
# Verify the handler was created successfully
254254
assert handler is not None
255255
assert handler.client is not None
256256

257257

258258
@pytest.mark.asyncio
259-
async def test_get_async_httpx_client_with_existing_session():
260-
"""Test get_async_httpx_client with existing session"""
259+
async def test_get_async_httpx_client_with_shared_session():
260+
"""Test get_async_httpx_client with shared session"""
261261
from litellm.llms.custom_httpx.http_handler import get_async_httpx_client
262262
from litellm.types.utils import LlmProviders
263263

264-
# Create a mock existing session
264+
# Create a mock shared session
265265
mock_session = MockClientSession()
266266

267-
# Test with existing session
267+
# Test with shared session
268268
client = get_async_httpx_client(
269269
llm_provider=LlmProviders.ANTHROPIC,
270-
existing_session=mock_session # type: ignore
270+
shared_session=mock_session # type: ignore
271271
)
272272

273273
# Verify the client was created successfully
@@ -276,15 +276,15 @@ async def test_get_async_httpx_client_with_existing_session():
276276

277277

278278
@pytest.mark.asyncio
279-
async def test_get_async_httpx_client_without_existing_session():
280-
"""Test get_async_httpx_client without existing session (backward compatibility)"""
279+
async def test_get_async_httpx_client_without_shared_session():
280+
"""Test get_async_httpx_client without shared session (backward compatibility)"""
281281
from litellm.llms.custom_httpx.http_handler import get_async_httpx_client
282282
from litellm.types.utils import LlmProviders
283283

284-
# Test without existing session
284+
# Test without shared session
285285
client = get_async_httpx_client(
286286
llm_provider=LlmProviders.ANTHROPIC,
287-
existing_session=None
287+
shared_session=None
288288
)
289289

290290
# Verify the client was created successfully
@@ -297,19 +297,19 @@ async def test_session_reuse_chain():
297297
"""Test that session is properly passed through the entire call chain"""
298298
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
299299

300-
# Create a mock existing session
300+
# Create a mock shared session
301301
mock_session = MockClientSession()
302302

303303
# Test the entire chain
304304
transport = AsyncHTTPHandler._create_async_transport(
305-
existing_session=mock_session # type: ignore
305+
shared_session=mock_session # type: ignore
306306
)
307307

308308
# Verify the transport was created
309309
assert transport is not None
310310

311311
# Test AsyncHTTPHandler creation
312-
handler = AsyncHTTPHandler(existing_session=mock_session) # type: ignore
312+
handler = AsyncHTTPHandler(shared_session=mock_session) # type: ignore
313313
assert handler is not None
314314

315315

@@ -359,12 +359,12 @@ async def test_session_reuse_integration():
359359
# Create two clients with the same session
360360
client1 = get_async_httpx_client(
361361
llm_provider=LlmProviders.ANTHROPIC,
362-
existing_session=mock_session # type: ignore
362+
shared_session=mock_session # type: ignore
363363
)
364364

365365
client2 = get_async_httpx_client(
366366
llm_provider=LlmProviders.OPENAI,
367-
existing_session=mock_session # type: ignore
367+
shared_session=mock_session # type: ignore
368368
)
369369

370370
# Both clients should be created successfully
@@ -386,16 +386,16 @@ async def test_session_validation():
386386
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
387387

388388
# Test with None session
389-
transport1 = AsyncHTTPHandler._create_aiohttp_transport(existing_session=None)
389+
transport1 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=None)
390390
assert callable(transport1.client) # Should create lambda
391391

392392
# Test with closed session
393393
mock_closed_session = MockClientSession()
394394
mock_closed_session.closed = True
395-
transport2 = AsyncHTTPHandler._create_aiohttp_transport(existing_session=mock_closed_session) # type: ignore
395+
transport2 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=mock_closed_session) # type: ignore
396396
assert callable(transport2.client) # Should create lambda
397397

398398
# Test with valid session
399399
mock_valid_session = MockClientSession()
400-
transport3 = AsyncHTTPHandler._create_aiohttp_transport(existing_session=mock_valid_session) # type: ignore
400+
transport3 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=mock_valid_session) # type: ignore
401401
assert transport3.client is mock_valid_session # Should reuse session

0 commit comments

Comments
 (0)