Skip to content

Commit 90d5307

Browse files
author
Bruce Adams
committed
fix: Default timeout for requests.request()
This avoids a hard-to-diagnose hang condition when a request never gets a response (which often means a network level failure occurred). Strongly recommended by Python Requests for production use. See: http://docs.python-requests.org/en/master/user/quickstart/#timeouts
1 parent b4754c9 commit 90d5307

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

watson_developer_cloud/watson_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ def request(self, method, url, accept_json=False, headers=None,
446446
else:
447447
params['api_key'] = self.api_key
448448

449+
# Use a one minute timeout when our caller doesn't give a timeout.
450+
# http://docs.python-requests.org/en/master/user/quickstart/#timeouts
451+
kwargs = dict({"timeout": 60}, **kwargs)
449452
kwargs = dict(kwargs, **self.http_config)
450453

451454
if self.verify is not None:

0 commit comments

Comments
 (0)