Skip to content

Commit 4e016a8

Browse files
fix: add configurable HTTP request timeout (default 30s)
The SDK's _request() method called session.request() without any timeout parameter, causing all HTTP calls to block indefinitely if the API server is slow or unresponsive. This could exhaust worker threads in consuming applications and halt payment processing. Added a configurable 'timeout' constructor parameter (default 30s) that is passed to every requests.Session.request() call. Co-authored-by: Babacar Diop <princemuichkine@users.noreply.github.com>
1 parent ec87b5b commit 4e016a8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lomi/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ def _flatten_data(data):
1919
class LomiClient:
2020
"""Merchant API client (public routes only)."""
2121

22+
DEFAULT_TIMEOUT = 30
23+
2224
def __init__(
2325
self,
2426
api_key: str,
2527
base_url: str = "https://api.lomi.africa",
2628
environment: str = "live",
29+
timeout: Optional[int] = None,
2730
):
2831
self.api_key = api_key
32+
self.timeout = timeout if timeout is not None else self.DEFAULT_TIMEOUT
2933
test_host = environment in ("test", "sandbox") or (
3034
isinstance(environment, str) and environment.lower() == "test"
3135
)
@@ -70,6 +74,7 @@ def _request(
7074
url=url,
7175
params=params,
7276
json=json_data,
77+
timeout=self.timeout,
7378
)
7479

7580
if response.status_code == 401:

0 commit comments

Comments
 (0)