Skip to content

Commit

Permalink
Merge pull request #30 from msabramo/wait_for_temp_file
Browse files Browse the repository at this point in the history
Retry opening output_file if it fails
  • Loading branch information
peterkeen committed Feb 8, 2015
2 parents fae0ab0 + 9c7e0fb commit eddde56
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/docverter-server/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ 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
num_tries += 1
break
rescue
puts "Failed to open #{output_file}; num_tries = #{num_tries}"
sleep 0.020
end
end

@output
end

Expand Down

0 comments on commit eddde56

Please sign in to comment.