Make sure read_one_line and write_one_line explicitly flush the
file rather than letting it garbage collect. Per luyer:
Technically, it is better to close a file than to let it go
out of scope. If a buffered write fails when the file goes
out of scope, we don't get an exception (Python prints something
to stderr, but the program continues).
Except we don't actually close it because that breaks the unittest
Flush achieves the same thing.
Signed-off-by: Martin Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@2248 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 5fa0e43..8132e9f 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -114,7 +114,9 @@
def write_one_line(filename, str):
- open(filename, 'w').write(str.rstrip('\n') + '\n')
+ f = open(filename, 'w')
+ f.write(str.rstrip('\n') + '\n')
+ f.flush()
def read_keyval(path):