Skip to content

Commit 3286220

Browse files
committed
Timeout added for opener
Fixes #20
1 parent adf4a31 commit 3286220

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python_http_client/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,20 @@ def _build_client(self, name=None):
143143
url_path=url_path,
144144
append_slash=self.append_slash)
145145

146-
def _make_request(self, opener, request):
146+
def _make_request(self, opener, request, timeout=4):
147147
"""Make the API call and return the response. This is separated into
148148
it's own function, so we can mock it easily for testing.
149149
150150
:param opener:
151151
:type opener:
152152
:param request: url payload to request
153153
:type request: urllib.Request object
154+
:param timeout: timeout for request in seconds, default 4 sec
155+
:type integer:
154156
:return: urllib response
155157
"""
156158
try:
157-
return opener.open(request)
159+
return opener.open(request, timeout=timeout)
158160
except HTTPError as err:
159161
exc = handle_error(err)
160162
exc.__cause__ = None

0 commit comments

Comments
 (0)