ruby-changes:50113
From: k0kubun <ko1@a...>
Date: Mon, 5 Feb 2018 22:24:05 +0900 (JST)
Subject: [ruby-changes:50113] k0kubun:r62231 (trunk): tool/downloader.rb: retry SocketError
k0kubun 2018-02-05 22:24:00 +0900 (Mon, 05 Feb 2018) New Revision: 62231 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62231 Log: tool/downloader.rb: retry SocketError I would like to stabilize RubyCI. https://rubyci.org/logs/rubyci.s3.amazonaws.com/fedora26/ruby-trunk/log/20180205T123003Z.fail.html.gz downloading did_you_mean-1.2.0.gem ... /home/hsbt/chkbuild/tmp/build/20180205T123003Z/tmp/ruby-snapshot20180205-23226-3201ha/ruby-2.6.0-r62226/tool/downloader.rb:212:in `rescue in download': failed to download did_you_mean-1.2.0.gem (RuntimeError) SocketError: Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Name or service not known): https://rubygems.org/downloads/did_you_mean-1.2.0.gem from /home/hsbt/chkbuild/tmp/build/20180205T123003Z/tmp/ruby-snapshot20180205-23226-3201ha/ruby-2.6.0-r62226/tool/downloader.rb:123:in `download' from /home/hsbt/chkbuild/tmp/build/20180205T123003Z/tmp/ruby-snapshot20180205-23226-3201ha/ruby-2.6.0-r62226/tool/downloader.rb:66:in `download' from -e:4:in `<main>' make[1]: *** [Makefile:1685: update-gems] Error 1 Modified files: trunk/tool/downloader.rb Index: tool/downloader.rb =================================================================== --- tool/downloader.rb (revision 62230) +++ tool/downloader.rb (revision 62231) @@ -161,7 +161,7 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L161 $stdout.flush end begin - data = with_retry(3, Errno::ETIMEDOUT) do + data = with_retry(3, [Errno::ETIMEDOUT, SocketError]) do url.read(options.merge(http_options(file, since.nil? ? true : since))) end rescue OpenURI::HTTPError => http_error @@ -267,11 +267,11 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L267 end end - def self.with_retry(max_times, exception, &block) + def self.with_retry(max_times, exceptions, &block) times = 0 begin block.call - rescue exception => e + rescue *exceptions => e times += 1 if times <= max_times $stderr.puts "retrying #{e.class} (#{e.message}) after #{times ** 2} seconds..." -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/