From patchwork Mon Nov 17 16:23:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 5322581 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1FF75C11AC for ; Mon, 17 Nov 2014 16:23:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55E162012B for ; Mon, 17 Nov 2014 16:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78EA120127 for ; Mon, 17 Nov 2014 16:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750823AbaKQQXm (ORCPT ); Mon, 17 Nov 2014 11:23:42 -0500 Received: from mail-ie0-f182.google.com ([209.85.223.182]:62436 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbaKQQXl (ORCPT ); Mon, 17 Nov 2014 11:23:41 -0500 Received: by mail-ie0-f182.google.com with SMTP id x19so181759ier.13 for ; Mon, 17 Nov 2014 08:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=XTEXBpIr3bR15qxYLT25crV1anaICL5uB1AqXyUoPmQ=; b=qJVzbFM29vnGVkPsbiT6hEXHdefU17raXUEr3jFIDFBP4hTKG7KzZiS2Y4iVgyiAhK dzKM/x2wH4qPlBSQiPTAZNQY/hV4pEYEZMIWcyPwD1vSGPTS83pTgroikGXvBnnh4j3A T+xFTue/iQoz6gYH8qk+EJwPr1VCjZc+ZybFnb/8p3ZJ0f9FQKzhdAgIqsVJ0y6pAkfA H+BFtF8jgziX2mBOtfjWe5Ss6QplaAyFLxOZkXnpgZdVg+mUFA8Hi7OsU8hh/pzXr8WA +STGX03dkLoCw+ZGmo81LlgxEUkAYrU8j91tjKcQg/vmDx07CiPBeZGeWRkQszdHkGYa Wx2Q== X-Received: by 10.107.25.20 with SMTP id 20mr2593017ioz.90.1416241421068; Mon, 17 Nov 2014 08:23:41 -0800 (PST) Received: from manet.1015granger.net ([2604:8800:100:81fc:82ee:73ff:fe43:d64f]) by mx.google.com with ESMTPSA id ik2sm6163005igb.9.2014.11.17.08.23.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2014 08:23:40 -0800 (PST) Subject: [PATCH] mountstats: Fix spurious I/O errors From: Chuck Lever To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Date: Mon, 17 Nov 2014 11:23:39 -0500 Message-ID: <20141117162339.15387.88477.stgit@manet.1015granger.net> User-Agent: StGit/0.17.1-3-g7d0f MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- tools/mountstats/mountstats.py | 4 ++++ 1 file changed, 4 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)