class Excon::Socket
def select_with_timeout(socket, type)
def select_with_timeout(socket, type) timeout_kind = type timeout = @data[OPERATION_TO_TIMEOUT[type]] # Check whether the request has a timeout configured. if @data.include?(:deadline) request_timeout = request_time_remaining # If the time remaining until the request times out is less than the timeout for the type of select, # use the time remaining as the timeout instead. if request_timeout < timeout timeout_kind = :request timeout = request_timeout end end select = case type when :connect_read IO.select([socket], nil, nil, timeout) when :connect_write IO.select(nil, [socket], nil, timeout) when :read IO.select([socket], nil, nil, timeout) when :write IO.select(nil, [socket], nil, timeout) end select || raise(Excon::Errors::Timeout.new("#{timeout_kind} timeout reached")) end