Method: RunLoop::ProcessWaiter#wait_for_any

Defined in:
lib/run_loop/process_waiter.rb

#wait_for_anyObject

Wait for ‘process_name` to start.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/run_loop/process_waiter.rb', line 94

def wait_for_any
  return true if running_process?

  now = Time.now
  poll_until = now + @options[:timeout]
  delay = @options[:interval]
  is_alive = false
  while Time.now < poll_until
    is_alive = running_process?
    break if is_alive
    sleep delay
  end

  RunLoop.log_debug("Waited for #{Time.now - now} seconds for '#{process_name}' to start.")

  if @options[:raise_on_timeout] and !is_alive
    raise "Waited #{@options[:timeout]} seconds for '#{process_name}' to start."
  end
  is_alive
end