Method: Selenium::WebDriver::WebSocketConnection#close

Defined in:
lib/selenium/webdriver/common/websocket_connection.rb

#closeObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/selenium/webdriver/common/websocket_connection.rb', line 53

def close
  @closing_mtx.synchronize do
    return if @closing

    @closing = true
  end

  begin
    socket.close
  rescue *CONNECTION_ERRORS => e
    WebDriver.logger.debug "WebSocket listener closed: #{e.class}: #{e.message}", id: :ws
    # already closed
  end

  # Let threads unwind instead of calling exit
  @socket_thread&.join(0.5)
  @callback_threads.list.each do |thread|
    thread.join(0.5)
  rescue StandardError => e
    WebDriver.logger.debug "Failed to join thread during close: #{e.class}: #{e.message}", id: :ws
  end
end