Skip to content

Instantly share code, notes, and snippets.

@doxavore
Created January 17, 2014 19:12
Show Gist options
  • Save doxavore/8479551 to your computer and use it in GitHub Desktop.
Save doxavore/8479551 to your computer and use it in GitHub Desktop.
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