Browse Source

workaround for twitter sending two elements in the rate limit

master
Julio Biason 15 years ago
parent
commit
5ab5ee7e7b
  1. 10
      mitterlib/network/twitter.py

10
mitterlib/network/twitter.py

@ -149,7 +149,7 @@ class TwitterNetworkData(NetworkData):
if 'in_reply_to_status_id' in data and data['in_reply_to_status_id']:
owner = NetworkUser()
owner.username = data['in_reply_to_screen_name']
self.parent = int(data['in_reply_to_status_id'])
self.parent = data['in_reply_to_status_id']
self.parent_owner = owner
if 'retweeted_status' in data:
@ -308,10 +308,14 @@ class Connection(NetworkBase):
# Introduced in Twitter in 2009.03.27
response_headers = response.info()
if 'X-RateLimit-Remaining' in response_headers:
self._rate_limit = int(response_headers['X-RateLimit-Remaining'])
rate = response_headers['X-RateLimit-Remaining'].split(',')[0]
_log.debug('X-RateLimit-Remaining: %s', rate)
self._rate_limit = int(rate)
_log.debug('Remaning hits: %d', self._rate_limit)
elif 'x-ratelimit-remaining' in response_headers:
self._rate_limit = int(response_headers['x-ratelimit-remaining'])
rate = response_headers['x-ratelimit-remaining'].split(',')[0]
_log.debug('x-ratelimit-remaining: %s', rate)
self._rate_limit = int(rate)
_log.debug('Remaning hits: %d', self._rate_limit)
else:
self._rate_limit = None

Loading…
Cancel
Save