summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2014-11-17 12:56:44 -0500
committerSteve Dickson <steved@redhat.com>2014-11-17 12:59:53 -0500
commit22656570c024e378baf66ca26fe2ab2bcc897129 (patch)
tree4a7a9c1e6eb3961c39d39846e8ba27c58886dcac
parente4569a0961ff9f059b9ae71327d291cf95399597 (diff)
downloadnfs-utils-22656570c024e378baf66ca26fe2ab2bcc897129.tar.gz
nfs-utils-22656570c024e378baf66ca26fe2ab2bcc897129.tar.xz
nfs-utils-22656570c024e378baf66ca26fe2ab2bcc897129.zip
mountstats: Fix spurious I/O errors
When running mountstats under "watch," occassionally the output shows "close failed in file object desctructor: sys.excepthook is missing" and the data display is messed up. This seems to be a common problem when Python script output is piped to another program. Ensure stdout/stderr is completely flushed before mountstats exits, and add an IOError exception handler to catch these exceptions gracefully. Solution suggested by: http://bugs.python.org/issue11380 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--tools/mountstats/mountstats.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index 9a6ec43..e6a456c 100644
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -612,8 +612,12 @@ try:
nfsstat_command()
elif prog == 'ms-iostat':
iostat_command()
+ sys.stdout.close()
+ sys.stderr.close()
except KeyboardInterrupt:
print('Caught ^C... exiting')
sys.exit(1)
+except IOError:
+ pass
sys.exit(0)