Commit 2a68efd6 by 徐向阳 Committed by GitHub
parent de216ee7
......@@ -145,23 +145,19 @@ module IGeTui
req = Net::HTTP::Post.new(url.path, initheader = { 'Content-Type' => 'application/json' })
req.body = data
is_fail = true
retry_time_limit = 3
try_time = 0
while is_fail && try_time < retry_time_limit
begin
res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
is_fail = false
rescue
is_fail = true
rescue => e
try_time += 1
puts ('try ' + try_time.to_s + ' time failed, time out.')
if try_time >= 3
raise e
else
retry
end
end
JSON.parse res.body
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