3.0.2 - Handle rate limitation in archiver

This commit is contained in:
Jaiden Mispy 2014-12-06 00:07:31 +11:00
parent b738f1fe3a
commit 458b94a4c3
2 changed files with 9 additions and 3 deletions

View file

@ -73,10 +73,16 @@ module Ebooks
loop do
opts[:max_id] = max_id unless max_id.nil?
new = @client.user_timeline(@username, opts)
begin
new = @client.user_timeline(@username, opts)
rescue Twitter::Error::TooManyRequests
log "Rate limit exceeded. Waiting for 5 mins before retry."
sleep 60*5
retry
end
break if new.length <= 1
tweets += new
puts "Received #{tweets.length} new tweets"
log "Received #{tweets.length} new tweets"
max_id = new.last.id
end