Skip to content

Instantly share code, notes, and snippets.

@wagurano
Created May 30, 2013 04:36
Show Gist options
  • Save wagurano/5675739 to your computer and use it in GitHub Desktop.
Save wagurano/5675739 to your computer and use it in GitHub Desktop.
inner timeout
#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