Sleep each query of the 5 tries and not only the first one.
This commit is contained in:
parent
3041c7f094
commit
7600b3855b
|
@ -21,18 +21,22 @@ module MusicBrainz
|
|||
private
|
||||
|
||||
def self.get_contents url
|
||||
time_passed = Time.now.to_f - @@last_query_time
|
||||
sleep @@query_interval - time_passed if time_passed < @@query_interval
|
||||
response = nil
|
||||
|
||||
5.times do
|
||||
time_passed = Time.now.to_f - @@last_query_time
|
||||
sleep @@query_interval - time_passed if time_passed < @@query_interval
|
||||
|
||||
begin
|
||||
response = open(url, "User-Agent" => USER_AGENT)
|
||||
@@last_query_time = Time.now.to_f
|
||||
rescue => e
|
||||
return nil if e.io.status[0].to_i == 404
|
||||
end
|
||||
|
||||
break unless response.nil?
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue