Skip to content

Commit

Permalink
rb: Add private Service#process_running? and Service#process_exited?
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 31, 2016
1 parent 82f6020 commit 7143ecc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(executable_path, port, *extra_args)
end

def start
if @process && @process.alive?
if process_running?
raise "already started: #{uri.inspect} #{@executable_path.inspect}"
end

Expand All @@ -61,8 +61,7 @@ def start
end

def stop
return if @process.nil? || @process.exited?

return if process_exited?
stop_server
ensure
stop_process
Expand Down Expand Up @@ -101,6 +100,14 @@ def stop_process
@process.stop STOP_TIMEOUT
end

def process_running?
@process && @process.alive?
end

def process_exited?
@process.nil? || @process.exited?
end

def connect_until_stable
socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
return if socket_poller.connected?
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(opts = {})
if opts.has_key?(:url)
url = opts.delete(:url)
else
@service = Service.default_service(*extract_service_args(opts))
@service = Service.new(Edge.driver_path, Service::DEFAULT_PORT, *extract_service_args(opts))

if @service.instance_variable_get("@host") == "127.0.0.1"
@service.instance_variable_set("@host", 'localhost')
Expand Down

0 comments on commit 7143ecc

Please sign in to comment.