def get_api(): auth = RateLimitHandler(CONSUMER_KEY, CONSUMER_SECRET) for key, secret in ACCESS_TOKENS: try: auth.add_access_token(key, secret) except TweepError, e: print key, e
def get_api(): auth = RateLimitHandler(CONSUMER_KEY, CONSUMER_SECRET) for key, secret in ACCESS_TOKENS: try: auth.add_access_token(key, secret) except TweepError as e: print(key, e) print('Token pool size:', len(auth.tokens)) api = API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) return api