Skip to content

Instantly share code, notes, and snippets.

@doxavore
Created January 17, 2014 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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