Change client timeout and make sure there is always a client available
This commit is contained in:
parent
25434c676c
commit
d1a2b193aa
@ -47,10 +47,10 @@ CONTEXT.add_options(
|
|||||||
OpenSSL::SSL::Options::NO_SSL_V2 |
|
OpenSSL::SSL::Options::NO_SSL_V2 |
|
||||||
OpenSSL::SSL::Options::NO_SSL_V3
|
OpenSSL::SSL::Options::NO_SSL_V3
|
||||||
)
|
)
|
||||||
pool = Deque.new((threads * 1.2).to_i) do
|
pool = Deque.new((threads * 1.2 + 1).to_i) do
|
||||||
client = HTTP::Client.new(URL, CONTEXT)
|
client = HTTP::Client.new(URL, CONTEXT)
|
||||||
client.read_timeout = 5.seconds
|
client.read_timeout = 10.seconds
|
||||||
client.connect_timeout = 5.seconds
|
client.connect_timeout = 10.seconds
|
||||||
client
|
client
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ threads.times do
|
|||||||
|
|
||||||
if rand(300) < 1
|
if rand(300) < 1
|
||||||
client = HTTP::Client.new(URL, CONTEXT)
|
client = HTTP::Client.new(URL, CONTEXT)
|
||||||
client.read_timeout = 5.seconds
|
client.read_timeout = 10.seconds
|
||||||
client.connect_timeout = 5.seconds
|
client.connect_timeout = 10.seconds
|
||||||
pool << client
|
pool << client
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ threads.times do
|
|||||||
rescue ex
|
rescue ex
|
||||||
io << id << " : " << ex << "\n"
|
io << id << " : " << ex << "\n"
|
||||||
client = HTTP::Client.new(URL, CONTEXT)
|
client = HTTP::Client.new(URL, CONTEXT)
|
||||||
client.read_timeout = 5.seconds
|
client.read_timeout = 10.seconds
|
||||||
client.connect_timeout = 5.seconds
|
client.connect_timeout = 10.seconds
|
||||||
pool << client
|
pool << client
|
||||||
next
|
next
|
||||||
ensure
|
ensure
|
||||||
|
Loading…
Reference in New Issue
Block a user