class SafeExec::PipeExecutor::TimeoutDelegate
Public Class Methods
new(executor, timeout, exception)
click to toggle source
# File lib/safe_exec/pipe_executor.rb, line 77 def initialize(executor, timeout, exception) @executor, @timeout, @exception = executor, timeout, exception end
Public Instance Methods
run(cmd, *args) { |t| ... }
click to toggle source
# File lib/safe_exec/pipe_executor.rb, line 81 def run(cmd, *args) @executor.run(cmd, *args) do |t| begin Timeout.timeout(@timeout, @exception) do yield t if block_given? t.value end rescue @exception => e begin @executor.send(:abort) Process.kill("TERM", t.pid) rescue Errno::ESRCH ensure raise e end end end end