toshiro92 toshiro92 - 1 year ago 142
Python Question

Tweepy does not handle 429 HTTP error (Too many Requests)

I am currently using Tweepy library, and I launched it since several days. However after a while, I received the following message between each tweet collected:

HTTP Error 429: Too Many Requests


Service not available

I thought set as True the function
while handle this kind of thing, or maybe it does not take account of 429 error ? I just requested about 10 terms in my filter, which returns around 1 tweet per 5-10 sec maximum.

How can I handle this kind of issue ? There is my piece of code btw:

streamer = tweepy.Stream(auth=api.auth, listener=StreamListener(), timeout=3000000000)

class StreamListener(tweepy.StreamListener):
status_wrapper = TextWrapper(width=60, initial_indent=' ', subsequent_indent=' ')

def on_status(self, status):
print ('{} {} - {}'.format(, status.created_at,status.text))
def on_disconnect(self, notice):
print ("Disconnect: {}".format(notice))

def on_warning(self, notice):
print ("Warning: {}".format(notice))

def on_exception(self, exception):
print ("Exception: ".format(exception))
def on_error(self, status_code):
if (status_code == 403):
print("Limit probably reached")
print("Error occured > {}".format(status_code))
return False

Answer Source


For those who have the same issue, just upgrade Tweepy ! I raised an issue on the Github's Tweepy project, and it has been solved. Please see issue #791 for more information

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download