Created
May 30, 2013 04:36
-
-
Save wagurano/5675739 to your computer and use it in GitHub Desktop.
inner timeout
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
#encoding: utf-8 | |
require 'timeout' | |
rt = 10 | |
begin # A | |
Timeout::timeout(5) { | |
# to do something | |
h_rt = 10 | |
begin # B | |
Timeout::timeout(5) { | |
# to do something | |
} | |
rescue Timeout::Error | |
h_rt -= 1 | |
if h_rt > 0 | |
sleep 1 | |
retry # where begin_A ? begin_B ? | |
else | |
raise | |
end | |
end | |
} | |
rescue Timeout::Error | |
rt -= 1 | |
if rt > 0 | |
sleep 1 | |
retry | |
else | |
raise | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment