Last night at around 1 am i hit Twitter’s search api rate limit which caused my Twitter Spam Assassin to stop working for several hours. The search api rate limit is very similar to the REST api rate limit, but is completely separate. The REST api limit is 350 an hour but the search api is publicly unknown. Twitter hasn’t released the number publicly due to security reasons. But, Twitter does say if you have a unique User-Agent in your header, you should get a higher limit. So I added a user-agent to my tweepy streaming api calls and we’ll see how that holds up.
In addition, I added some code to be able to handle this particular issue if it comes up. Prior, my code didn’t know it was happening and therefore didn’t know how to resolve it properly.
Added the following to my Listener object
def on_error(self, status_code): logging.error('Encountered error with status code: ' + str(status_code)) if status_code == 420: time.sleep(600) return True # Don't kill the stream