Commit ac62f7f2 authored by drevicko's avatar drevicko
Browse files

added timeout to api constructor with default 60s, set timeout when creating...

added timeout to api constructor with default 60s, set timeout when creating HTTPConnection and HTTPSConnection in binder.py
	modified:   tweepy/api.py
	modified:   tweepy/binder.py
parent a31d7952
......@@ -17,7 +17,7 @@ class API(object):
def __init__(self, auth_handler=None,
host='api.twitter.com', search_host='search.twitter.com',
cache=None, secure=True, api_root='/1.1', search_root='',
retry_count=0, retry_delay=0, retry_errors=None,
retry_count=0, retry_delay=0, retry_errors=None, timeout=60,
parser=None):
self.auth = auth_handler
self.host = host
......@@ -29,6 +29,7 @@ class API(object):
self.retry_count = retry_count
self.retry_delay = retry_delay
self.retry_errors = retry_errors
self.timeout = timeout
self.parser = parser or ModelParser()
""" statuses/home_timeline """
......
......@@ -130,9 +130,9 @@ def bind_api(**config):
# Open connection
# FIXME: add timeout
if self.api.secure:
conn = httplib.HTTPSConnection(self.host)
conn = httplib.HTTPSConnection(self.host,timeout=self.api.timeout)
else:
conn = httplib.HTTPConnection(self.host)
conn = httplib.HTTPConnection(self.host,timeout=self.api.timeout)
# Apply authentication
if self.api.auth:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment