This commit is contained in:
amarrtech 2026-09-30 10:33:24 -04:00 • committed by GitHub
commit 58da8a8b53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -1796,7 +1796,11 @@ def _get_httpx_client(params: dict | None = None) -> HTTPHandler:
if params is not None:
# Filter out params that are only used for cache key, not for HTTPHandler.__init__
handler_params: Final = {k: v for k, v in params.items() if k != "disable_aiohttp_transport"}
configured_timeout: Final = params.get("timeout")
handler_params: Final = {
**{k: v for k, v in params.items() if k not in ("disable_aiohttp_transport", "timeout")},
"timeout": configured_timeout if configured_timeout is not None else _default_cached_client_timeout(),
}
_new_client = HTTPHandler(**handler_params)
else:
_new_client = HTTPHandler(timeout=_default_cached_client_timeout())

View file

@ -741,6 +741,18 @@ class TestDefaultCachedClientTimeoutHonorsRequestTimeout:
client = get_async_httpx_client(llm_provider=LlmProviders.BEDROCK)
assert client.timeout.read == 300.0
def test_cached_sync_client_with_none_timeout_uses_explicit_request_timeout(self, monkeypatch: pytest.MonkeyPatch):
from litellm.caching.llm_caching_handler import LLMClientCache
monkeypatch.setattr(litellm, "request_timeout", 300)
monkeypatch.setattr(litellm, "request_timeout_explicitly_set", True)
monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache())
client = _get_httpx_client(params={"timeout": None})
request = client.client.build_request("GET", "https://example.com")
assert request.extensions["timeout"]["read"] == 300.0
async def _read_http_request(reader: asyncio.StreamReader) -> None:
raw = b""