问题描述:

i want a ruby script to terminate on infinite loops OR if a ruby script takes more than 10 seconds than terminate the script itself. I know using ctrl key or any keyboard interruption i can do so , but i want the script to terminate automatically by itself if it takes more than 10 seconds

网友答案:
require "timeout"
Timeout.timeout(10) do
  loop do
    ...
  end
end
相关阅读:
Top