Merge pull request #342 from dalleng/master

Fix issue #317 TwythonRateLimitError.retry_after is always None.
This commit is contained in:
Mike Helmick 2014-10-30 11:11:40 -04:00
commit 6662ff4061

View file

@ -192,10 +192,10 @@ class Twython(EndpointsMixin, object):
# app keys/user tokens # app keys/user tokens
ExceptionType = TwythonAuthError ExceptionType = TwythonAuthError
raise ExceptionType(error_message, raise ExceptionType(
error_code=response.status_code, error_message,
retry_after=response.headers.get('retry-\ error_code=response.status_code,
after')) retry_after=response.headers.get('X-Rate-Limit-Reset'))
try: try:
content = response.json() content = response.json()
@ -497,8 +497,7 @@ class Twython(EndpointsMixin, object):
# Add 1 to the id because since_id and # Add 1 to the id because since_id and
# max_id are inclusive # max_id are inclusive
if hasattr(function, 'iter_metadata'): if hasattr(function, 'iter_metadata'):
since_id = content[function.iter_metadata]\ since_id = content[function.iter_metadata].get('since_id_str')
.get('since_id_str')
else: else:
since_id = content[0]['id_str'] since_id = content[0]['id_str']
params['since_id'] = (int(since_id) - 1) params['since_id'] = (int(since_id) - 1)