From 55014a263da5dce5b4014babbda2ff412f6f82d5 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 19 Jul 2007 20:02:26 +0000 Subject: Hopefully fixing #720 -- I added tests and a lame back-off system to give the child process time to write git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2717 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/util.rb | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 3f8007260..d1d14977c 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -342,9 +342,30 @@ module Util # read output in if required if ! arguments[:squelch] - output = output_file.open.read - output_file.close - output_file.delete + + # Make sure the file's actually there. This is + # basically a race condition, and is probably a horrible + # way to handle it, but, well, oh well. + unless FileTest.exists?(output_file.path) + Puppet.warning "sleeping" + sleep 0.5 + unless FileTest.exists?(output_file.path) + Puppet.warning "sleeping 2" + sleep 1 + unless FileTest.exists?(output_file.path) + Puppet.warning "Could not get output" + output = "" + end + end + end + unless output + # We have to explicitly open here, so that it reopens + # after the child writes. + output = output_file.open.read + + # The 'true' causes the file to get unlinked right away. + output_file.close(true) + end end if arguments[:failonfail] -- cgit