【发布时间】:2014-06-22 15:39:41
【问题描述】:
我在循环中有这段 ruby 代码:
pid = Process.spawn("my_process_command")
begin
Timeout.timeout(16) do
`my_timeout_command`
Process.wait(pid)
end
rescue
system("clear")
puts 'Process not finished in time, killing it'
Process.kill('TERM', pid)
end
问题是一旦 Timeout::Error 异常被捕获,块将被跳过并且循环实际上什么都不做。我该如何解决这个问题?
【问题讨论】: