Skip to content

Commit 3e1ce5e

Browse files
committed
Merge pull request #12 from holm/master
Support setting timeout of connection
2 parents 85f4cf4 + 25b5471 commit 3e1ce5e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

embedly/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Embedly(object):
2222
Client
2323
2424
"""
25-
def __init__(self, key=None, user_agent=USER_AGENT):
25+
def __init__(self, key=None, user_agent=USER_AGENT, timeout=60):
2626
"""
2727
Initialize the Embedly client
2828
@@ -34,6 +34,7 @@ def __init__(self, key=None, user_agent=USER_AGENT):
3434
:returns: None
3535
"""
3636
self.user_agent = user_agent
37+
self.timeout = timeout
3738
self.key = key
3839
self.services = []
3940

@@ -49,7 +50,7 @@ def get_services(self):
4950

5051
url = 'http://api.embed.ly/1/services/python'
5152

52-
http = httplib2.Http()
53+
http = httplib2.Http(timeout=self.timeout)
5354
headers = {'User-Agent' : self.user_agent}
5455
resp, content = http.request(url, headers=headers)
5556

@@ -118,7 +119,7 @@ def _get(self, version, method, url_or_urls, **kwargs):
118119

119120
url = 'http://api.embed.ly/%s/%s?%s' % (version, method, query)
120121

121-
http = httplib2.Http()
122+
http = httplib2.Http(timeout=self.timeout)
122123

123124
headers = {'User-Agent' : self.user_agent}
124125

0 commit comments

Comments
 (0)