Created
November 10, 2010 09:10
-
-
Save baya/670581 to your computer and use it in GitHub Desktop.
help method for visting a url
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
module Rubber | |
def self.try(diftimes = [3, 8, 2], options = { }, &block) | |
val = timeout(diftimes.shift) do | |
block.call | |
end | |
rescue options[:on] || Exception => e | |
Rails.logger.info("#{Time.now}:#{__FILE__}:#{__LINE__}}:#{e.backtrace.join("\n")}") | |
retry if diftimes.first | |
return "" | |
else | |
val | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment