I am not trying to reconnect very often.
This is the code which does the streaming.
class MyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
feed = data
print feed
def on_error(self, status_code, data):
print status_code
logger.error("Rate limited, sleeping for 3000")
time.sleep(3000)
TwitterCheckin()
# Want to stop trying to get data because of the error?
# Uncomment the next line!
# self.disconnect()
def TwitterCheckin():
stream_user = UserSocialAuth.objects.get(provider=‘twitter’, uid=’<TWITTER_ID>’)
stream_user.refresh_token()
stream = MyStreamer(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET,
stream_user.tokens[‘oauth_token’], stream_user.tokens[‘oauth_token_secret’])
logger.error(“Stream started”)
stream.statuses.filter(track=’#testinghere’)
I make a call to TwitterCheckin() only once in the entire lifetime of the code which this is part of.
status_code return 420 as soon as I make the call to TwitterCheckin()