当前位置: 动力学知识库 > 问答 > 编程问答 >

Terminate ruby script on infinite loops

问题描述:

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
分享给朋友:
您可能感兴趣的文章:
随机阅读: