diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-19 20:02:26 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-19 20:02:26 +0000 |
commit | 55014a263da5dce5b4014babbda2ff412f6f82d5 (patch) | |
tree | 83833d495bf14a16a33560f57f57a70021e1eaad | |
parent | eacb06c2e82e52da033b701e4d7e0e4e2e0df61d (diff) | |
download | puppet-55014a263da5dce5b4014babbda2ff412f6f82d5.tar.gz puppet-55014a263da5dce5b4014babbda2ff412f6f82d5.tar.xz puppet-55014a263da5dce5b4014babbda2ff412f6f82d5.zip |
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
-rw-r--r-- | lib/puppet/util.rb | 27 |
1 files 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] |