def _handle_twitter_rate_limit(cursor):
'''Handle twitter rate limits. If rate limit is reached, the next element
will be accessed again after sleep time'''
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
log.info('Twitter API rate limit error. Sleeping for {} secs.') \
.format(TWITTER_API_RATE_LIMIT_PERIOD)
sleep_time = TWITTER_API_RATE_LIMIT_PERIOD
time.sleep(sleep_time)
except tweepy.TweepError as e:
if str(e.api_code) == TWITTER_API_USER_NOT_FOUND_ERROR_CODE:
raise ValueError(
'Requested user was not found. Check your configuration')
raise e
评论列表
文章目录