Created
September 16, 2012 01:32
-
-
Save jjb/3730697 to your computer and use it in GitHub Desktop.
Timeout raising an error wherever the inner code happens to be
This file contains hidden or 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' | |
Timeout.timeout(rand) do # random number between 0 and 1 (seconds) | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
end |
This file contains hidden or 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
➔ ruby code.rb | |
code.rb:5:in `sleep': execution expired (Timeout::Error) | |
from code.rb:5:in `block in <main>' | |
from code.rb:3:in `<main>' | |
➔ ruby code.rb | |
code.rb:6:in `sleep': execution expired (Timeout::Error) | |
from code.rb:6:in `block in <main>' | |
from code.rb:3:in `<main>' | |
➔ ruby code.rb | |
code.rb:10:in `sleep': execution expired (Timeout::Error) | |
from code.rb:10:in `block in <main>' | |
from code.rb:3:in `<main>' | |
➔ ruby code.rb | |
code.rb:4:in `sleep': execution expired (Timeout::Error) | |
from code.rb:4:in `block in <main>' | |
from code.rb:3:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment