From a9d868661285c82f8aa6231dac4cea81384fd2fd Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:54:29 +0530 Subject: [PATCH 1/6] feat: add configurable 30s default timeout to sync client --- openapi_python_sdk/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi_python_sdk/client.py b/openapi_python_sdk/client.py index 4b3cbd6..18b6341 100644 --- a/openapi_python_sdk/client.py +++ b/openapi_python_sdk/client.py @@ -14,8 +14,8 @@ class Client: Synchronous client for making authenticated requests to Openapi endpoints. """ - def __init__(self, token: str, client: Any = None): - self.client = client if client is not None else httpx.Client() + def __init__(self, token: str, client: Any = None, timeout: float = 30.0): + self.client = client if client is not None else httpx.Client(timeout=timeout) self.auth_header: str = f"Bearer {token}" self.headers: Dict[str, str] = { "Authorization": self.auth_header, From b062858753e18564e2f7c34d5348d309d133121a Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:55:02 +0530 Subject: [PATCH 2/6] feat: add configurable 30s default timeout to async client --- openapi_python_sdk/async_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi_python_sdk/async_client.py b/openapi_python_sdk/async_client.py index e0d0a05..fd6af56 100644 --- a/openapi_python_sdk/async_client.py +++ b/openapi_python_sdk/async_client.py @@ -10,8 +10,8 @@ class AsyncClient: Suitable for use with FastAPI, aiohttp, etc. """ - def __init__(self, token: str, client: Any = None): - self.client = client if client is not None else httpx.AsyncClient() + def __init__(self, token: str, client: Any = None, timeout: float = 30.0): + self.client = client if client is not None else httpx.AsyncClient(timeout=timeout) self.auth_header: str = f"Bearer {token}" self.headers: Dict[str, str] = { "Authorization": self.auth_header, From 197abf13602e03ef26ac89cdfbddd51fff5b9d12 Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:55:26 +0530 Subject: [PATCH 3/6] feat: add timeout parameter to sync oauth client initialization --- openapi_python_sdk/oauth_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi_python_sdk/oauth_client.py b/openapi_python_sdk/oauth_client.py index 61b583b..f6a418d 100644 --- a/openapi_python_sdk/oauth_client.py +++ b/openapi_python_sdk/oauth_client.py @@ -12,8 +12,8 @@ class OauthClient: Synchronous client for handling Openapi authentication and token management. """ - def __init__(self, username: str, apikey: str, test: bool = False, client: Any = None): - self.client = client if client is not None else httpx.Client() + def __init__(self, username: str, apikey: str, test: bool = False, client: Any = None, timeout: float = 30.0): + self.client = client if client is not None else httpx.Client(timeout=timeout) self.url: str = TEST_OAUTH_BASE_URL if test else OAUTH_BASE_URL self.auth_header: str = ( "Basic " + base64.b64encode(f"{username}:{apikey}".encode("utf-8")).decode() From 08d20100ac1e02b7c67182333f29f11ba9ce00dc Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:55:56 +0530 Subject: [PATCH 4/6] feat: add timeout parameter to async oauth client initialization --- openapi_python_sdk/async_oauth_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi_python_sdk/async_oauth_client.py b/openapi_python_sdk/async_oauth_client.py index c3234cf..1de3fbd 100644 --- a/openapi_python_sdk/async_oauth_client.py +++ b/openapi_python_sdk/async_oauth_client.py @@ -12,8 +12,8 @@ class AsyncOauthClient: Suitable for use with FastAPI, aiohttp, etc. """ - def __init__(self, username: str, apikey: str, test: bool = False, client: Any = None): - self.client = client if client is not None else httpx.AsyncClient() + def __init__(self, username: str, apikey: str, test: bool = False, client: Any = None, timeout: float = 30.0): + self.client = client if client is not None else httpx.AsyncClient(timeout=timeout) self.url: str = TEST_OAUTH_BASE_URL if test else OAUTH_BASE_URL self.auth_header: str = ( "Basic " + base64.b64encode(f"{username}:{apikey}".encode("utf-8")).decode() From 7c82c767aa23e32dcec4663145dddc68ee2fa3d8 Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:56:14 +0530 Subject: [PATCH 5/6] docs: add example usage for configuring network timeouts --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index b48d866..9c91bc2 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,18 @@ session.mount("https://", adapter) client = Client("token", client=session) ``` +### Configuring Network Timeouts + +By default, the SDK uses a 30-second timeout for all network requests to avoid hanging on slow network connections or heavy API operations. + +You can easily override it passing a `timeout` explicitly during initialization to all client variants: + +```python +from openapi_python_sdk import Client + +client = Client(token="token", timeout=60.0) # 60 seconds +``` + ## Async Usage The SDK provides `AsyncClient` and `AsyncOauthClient` for use with asynchronous frameworks like FastAPI or `aiohttp`. From 0b102111ff5907ef5a904bc38853d3e88327f928 Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 15 Apr 2026 22:56:32 +0530 Subject: [PATCH 6/6] docs: update pypi tables and snippets to highlight new timeout parameter --- docs/readme-pypi.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/readme-pypi.md b/docs/readme-pypi.md index 60c3790..fd93bb6 100644 --- a/docs/readme-pypi.md +++ b/docs/readme-pypi.md @@ -60,6 +60,16 @@ resp = client.request( ) ``` +### Configuring Network Timeouts + +By default, the SDK uses a 30-second timeout for all network requests. You can easily override it passing a `timeout` explicitly during initialization: + +```python +from openapi_python_sdk.client import Client + +client = Client(token="token", timeout=60.0) # 60 seconds +``` + ## Testing ```bash @@ -71,7 +81,7 @@ pytest | Method | Description | |---|---| -| `OauthClient(username, apikey, test=False)` | Initialize the OAuth client. Set `test=True` for sandbox. | +| `OauthClient(username, apikey, test=False, timeout=30.0)` | Initialize the OAuth client. Set `test=True` for sandbox. | | `create_token(scopes, ttl)` | Create a bearer token for the given scopes and TTL (seconds). | | `get_token(scope)` | Retrieve an existing token by scope. | | `delete_token(id)` | Revoke a token by ID. | @@ -82,7 +92,7 @@ pytest | Method | Description | |---|---| -| `Client(token)` | Initialize the client with a bearer token. | +| `Client(token, timeout=30.0)` | Initialize the client with a bearer token. | | `request(method, url, payload, params)` | Execute an HTTP request against any Openapi endpoint. | ## Links