Commit 2a68efd6 by 徐向阳 Committed by GitHub
parent de216ee7
...@@ -145,23 +145,19 @@ module IGeTui ...@@ -145,23 +145,19 @@ module IGeTui
req = Net::HTTP::Post.new(url.path, initheader = { 'Content-Type' => 'application/json' }) req = Net::HTTP::Post.new(url.path, initheader = { 'Content-Type' => 'application/json' })
req.body = data req.body = data
is_fail = true
retry_time_limit = 3
try_time = 0 try_time = 0
begin
while is_fail && try_time < retry_time_limit res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
begin rescue => e
res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) } try_time += 1
is_fail = false if try_time >= 3
rescue raise e
is_fail = true else
try_time += 1 retry
puts ('try ' + try_time.to_s + ' time failed, time out.')
end end
end end
JSON.parse res.body JSON.parse res.body
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment