Created
December 21, 2012 09:34
-
-
Save karlmikko/4351755 to your computer and use it in GitHub Desktop.
fixed!
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
def retryable(options = {}) | |
opts = { :tries => 1, :on => Exception }.merge(options) | |
retry_exception, retries = opts[:on], opts[:tries] | |
begin | |
return yield | |
rescue retry_exception | |
if (retries -= 1) > 0 | |
sleep 2 | |
retry | |
else | |
raise | |
end | |
end | |
end | |
def create_report | |
if @inspection.type == 'RoutineInspection' | |
puts "---CR> CREATING ROUTINE INSPECTION REPORT" | |
pdf = routine_inspection_generic | |
else | |
puts "---CR> CREATING INGOING INSPECTION REPORT" | |
thread = Thread.new do | |
pdf = ingoing_inspection_nsw | |
end | |
retryable(:tries => 10, :on => Timeout::Error) do | |
thread.join | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment