I expected that timeout will happen every 30 seconds in the following code:
def action_with_timeout(threshould, &block)
  begin
    Timeout::timeout(threshould) {block.call}
  rescue Exception => e
    ap("Timeout #{threshould}, stop loading pag, #{Time.now}")
    stop_loading_page
  end
end
while true
  action_with_timeout(30) {
    ap("to INDEX")
    browse_to(CONFIG["ROOT_URL"])
  }
end    
However, it only works for the first time. The remaining will timeout in a short time. The output is:
"Timeout 30, stop loading pag, 2015-07-01 19:59:10 +0800"
"Timeout 30, stop loading pag, 2015-07-01 19:59:13 +0800"
"Timeout 30, stop loading pag, 2015-07-01 19:59:16 +0800"
"Timeout 30, stop loading pag, 2015-07-01 19:59:19 +0800"
How can I fix it?