Sha256: bb93a00c8eb5c81d5587c7ea11b5a52cb76fd0e165f0d9ff0ccde28cbdb9d913

Contents?: true

Size: 480 Bytes

Versions: 4

Compression:

Stored size: 480 Bytes

Contents

require 'timeout'
require 'socket'

class TCPSocket
  
  def self.wait_for_service(options)
    socket = nil
    Timeout::timeout(options[:timeout] || 20) do
      loop do
        begin
          socket = TCPSocket.new(options[:host], options[:port])
          return
        rescue Errno::ECONNREFUSED,
               Errno::EBADF             # Windows
          puts ".\n"
          sleep 2
        end
      end
    end
  ensure
    socket.close unless socket.nil?
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
statt-0.0.4 lib/selenium-grid/lib/ruby/tcp_socket_extensions.rb
statt-0.0.3 lib/selenium-grid/lib/ruby/tcp_socket_extensions.rb
statt-0.0.2 lib/selenium-grid/lib/ruby/tcp_socket_extensions.rb
statt-0.0.1 lib/selenium-grid/lib/ruby/tcp_socket_extensions.rb