Commit 0b05a493 by Victor Wang Committed by GitHub

Merge pull request #21 from xuxiangyang/master

fix #issues/20
parents de216ee7 2a68efd6
...@@ -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