Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JRuby (tested on 1.7.4 and 1.7.9) exits after 10 seconds. MRI exits after 5 seconds.
require 'timeout'
puts "Starting at #{Time.now}"
begin
Timeout.timeout(5) do
`sleep 10`
puts 'after sleep'
end
rescue Timeout::Error
puts 'timed out'
end
puts "Ending at #{Time.now}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment