From 2b8ff01ab12ba294eb586d19916d581c1c00be59 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Fri, 6 Nov 2026 11:17:24 -0600 Subject: [PATCH] Disable read timeout on default low-level HTTP clients --- baseten/client/_inference.py | 4 ++++ baseten/client/_management.py | 4 ++++ baseten/client/_sandbox.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/baseten/client/_inference.py b/baseten/client/_inference.py index ea199e0..4f87a2b 100644 --- a/baseten/client/_inference.py +++ b/baseten/client/_inference.py @@ -128,9 +128,11 @@ def __init__( # Empty api_key is an advanced opt-out from sending Authorization. if api_key != "": request_headers["Authorization"] = f"Bearer {api_key}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.Client( base_url=self._options.base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True @@ -243,9 +245,11 @@ def __init__( # Empty api_key is an advanced opt-out from sending Authorization. if api_key != "": request_headers["Authorization"] = f"Bearer {api_key}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.AsyncClient( base_url=self._options.base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True diff --git a/baseten/client/_management.py b/baseten/client/_management.py index b83757c..85dcda2 100644 --- a/baseten/client/_management.py +++ b/baseten/client/_management.py @@ -79,9 +79,11 @@ def __init__( # Empty api_key is an advanced opt-out from sending Authorization. if api_key != "": request_headers["Authorization"] = f"Bearer {api_key}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.Client( base_url=self._options.base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True @@ -172,9 +174,11 @@ def __init__( # Empty api_key is an advanced opt-out from sending Authorization. if api_key != "": request_headers["Authorization"] = f"Bearer {api_key}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.AsyncClient( base_url=self._options.base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True diff --git a/baseten/client/_sandbox.py b/baseten/client/_sandbox.py index 6d26535..4292c0a 100644 --- a/baseten/client/_sandbox.py +++ b/baseten/client/_sandbox.py @@ -69,9 +69,11 @@ def __init__( # Empty token is an advanced opt-out from sending Authorization. if token != "": request_headers["Authorization"] = f"Bearer {token}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.Client( base_url=base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True @@ -156,9 +158,11 @@ def __init__( # Empty token is an advanced opt-out from sending Authorization. if token != "": request_headers["Authorization"] = f"Bearer {token}" + # No read timeout, matching the JS and Go clients. self._http_client = httpx.AsyncClient( base_url=base_url, headers=with_user_agent(request_headers), + timeout=httpx.Timeout(5.0, read=None), ) self.close_http_client_on_close = ( True