Skip to content

Instantly share code, notes, and snippets.

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