Skip to content

Commit

Permalink
Retry opening output_file if it fails
Browse files Browse the repository at this point in the history
Hoping that this fixes intermittent 500 errors due to inability to open
temp files, as seen in Docverter#28.
  • Loading branch information
msabramo committed Feb 2, 2015
1 parent 1f8eb8a commit d60306f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/docverter-server/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ class DocverterServer::App < Sinatra::Base

content_type(DocverterServer::ConversionTypes.mime_type(manifest['to']))

num_tries = 0
max_retries = 10
@output = nil
File.open(output_file) do |f|
@output = f.read

while num_tries < max_retries
begin
File.open(output_file) do |f|
@output = f.read
end
break
raise
puts "Failed to open #{output_file}"
sleep 0.020
end
end

@output
end

Expand Down

0 comments on commit d60306f

Please sign in to comment.