Skip to content

Instantly share code, notes, and snippets.

@karlmikko
Created December 21, 2012 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlmikko/4351755 to your computer and use it in GitHub Desktop.
Save karlmikko/4351755 to your computer and use it in GitHub Desktop.
fixed!
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
pdf
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment