Created
June 20, 2023 04:29
-
-
Save louishuyng/f75beecdfd8e9de4cd86cbfd3f4cdbdb to your computer and use it in GitHub Desktop.
Handling timeout error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'timeout' | |
begin | |
status = Timeout::timeout(5) { | |
# Something that should be interrupted if it takes too much time... | |
} | |
rescue Timeout::Error | |
puts 'That took too long, exiting...' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment