Skip to content

Commit 0d32532

Browse files
committed
feat: checking user passed timeout value
1 parent a1adbda commit 0d32532

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

portkey_ai/api_resources/base_client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,19 @@ def __init__(
182182
)
183183

184184
self.allHeaders = self._build_headers(Options.construct())
185+
186+
if self.request_timeout:
187+
timeout = httpx.Timeout(self.request_timeout, connect=5.0)
188+
else:
189+
timeout = DEFAULT_TIMEOUT_CONFIG
190+
185191
self._client = http_client or httpx.Client(
186192
base_url=self.base_url,
187193
headers={
188194
"Accept": "application/json",
189195
},
190196
limits=DEFAULT_CONNECTION_LIMITS,
191-
timeout=DEFAULT_TIMEOUT_CONFIG,
197+
timeout=timeout,
192198
)
193199

194200
self.response_headers: httpx.Headers | None = None
@@ -896,13 +902,19 @@ def __init__(
896902
)
897903

898904
self.allHeaders = self._build_headers(Options.construct())
905+
906+
if self.request_timeout:
907+
timeout = httpx.Timeout(self.request_timeout, connect=5.0)
908+
else:
909+
timeout = DEFAULT_TIMEOUT_CONFIG
910+
899911
self._client = http_client or AsyncHttpxClientWrapper(
900912
base_url=self.base_url,
901913
headers={
902914
"Accept": "application/json",
903915
},
904916
limits=DEFAULT_CONNECTION_LIMITS,
905-
timeout=DEFAULT_TIMEOUT_CONFIG,
917+
timeout=timeout,
906918
)
907919

908920
self.response_headers: httpx.Headers | None = None

0 commit comments

Comments
 (0)