Skip to content

Commit

Permalink
Added timeout (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
chickahoona committed Sep 4, 2024
1 parent 46caf7a commit 3ca3caf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion paddle_billing/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
logger: Logger = None,
retry_count: int = 3,
use_api_version: int = 1,
timeout: float = 60.0,
):
self.__api_key = api_key
self.retry_count = retry_count
Expand All @@ -58,6 +59,7 @@ def __init__(
self.options = options if options else Options()
self.log = logger if logger else Client.null_logger()
self.client = http_client if http_client else self.build_request_session()
self.timeout = timeout
self.payload = None # Used by pytest
self.status_code = None # Used by pytest

Expand Down Expand Up @@ -133,7 +135,7 @@ def _make_request(
self.payload = self.serialize_json_payload(payload) if payload else None
try:
# We use data= instead of json= because we manually serialize data into JSON
response = self.client.request(method.upper(), url, data=self.payload)
response = self.client.request(method.upper(), url, data=self.payload, timeout=self.timeout)
self.status_code = response.status_code
response.raise_for_status()

Expand Down

0 comments on commit 3ca3caf

Please sign in to comment.