mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(maint) Use timeout builtin to TCPSocket when opening sockets.
This commit is contained in:
parent
8344f89722
commit
60fe266c9e
1 changed files with 9 additions and 11 deletions
|
|
@ -540,17 +540,15 @@ module Vmpooler
|
||||||
},
|
},
|
||||||
kind: :client
|
kind: :client
|
||||||
) do
|
) do
|
||||||
Timeout.timeout(timeout) do
|
target_host = host
|
||||||
target_host = host
|
target_host = "#{host}.#{domain}" if domain
|
||||||
target_host = "#{host}.#{domain}" if domain
|
span = OpenTelemetry::Trace.current_span
|
||||||
span = OpenTelemetry::Trace.current_span
|
span.set_attribute('net.peer.name', target_host)
|
||||||
span.set_attribute('net.peer.name', target_host)
|
sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
|
||||||
sock = TCPSocket.new target_host, port
|
begin
|
||||||
begin
|
yield sock if block_given?
|
||||||
yield sock if block_given?
|
ensure
|
||||||
ensure
|
sock.close
|
||||||
sock.close
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue