public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mountstats: Fix spurious I/O errors
@ 2014-11-17 16:23 Chuck Lever
  2014-11-17 18:32 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Chuck Lever @ 2014-11-17 16:23 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

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>
---
 tools/mountstats/mountstats.py |    4 ++++
 1 file changed, 4 insertions(+)

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)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-17 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 16:23 [PATCH] mountstats: Fix spurious I/O errors Chuck Lever
2014-11-17 18:32 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox