aboutsummaryrefslogtreecommitdiffstats
path: root/tool/downloader.rb
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-11 04:22:14 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-11 04:22:14 +0000
commit92c03be88847118bb64fb3ce035520b049247af5 (patch)
tree29fc4263e45c25b1a226d3793f34a8ad1be87e6a /tool/downloader.rb
parent0f0d7805cb7e7f6f545176e3ef1a107051d413cb (diff)
downloadruby-92c03be88847118bb64fb3ce035520b049247af5.tar.gz
tool/downloader.rb: retry on 502 and 503 error
rubyci was failed by download 503 https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180811T021706Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/downloader.rb')
-rw-r--r--tool/downloader.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index c832b3ca9b..66de59066b 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -161,7 +161,7 @@ class Downloader
$stdout.flush
end
begin
- data = with_retry(3, [Errno::ETIMEDOUT, SocketError]) do
+ data = with_retry(3) do
url.read(options.merge(http_options(file, since.nil? ? true : since)))
end
rescue OpenURI::HTTPError => http_error
@@ -267,11 +267,12 @@ class Downloader
end
end
- def self.with_retry(max_times, exceptions, &block)
+ def self.with_retry(max_times, &block)
times = 0
begin
block.call
- rescue *exceptions => e
+ rescue Errno::ETIMEDOUT, SocketError, OpenURI::HTTPError => e
+ raise if e.is_a?(OpenURI::HTTPError) && e.message !~ /^50[23] / # retry only 502, 503 for http error
times += 1
if times <= max_times
$stderr.puts "retrying #{e.class} (#{e.message}) after #{times ** 2} seconds..."