From cf2b8b104b02ee532cb81259303b1d46cdd44703 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 18 Aug 2014 16:32:53 -0400 Subject: [PATCH] move the stderr/stdout closing to the ceph-deploy executable Signed-off-by: Alfredo Deza --- ceph_deploy/util/decorators.py | 1 - scripts/ceph-deploy | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ceph_deploy/util/decorators.py b/ceph_deploy/util/decorators.py index 4c72bdc..7589deb 100644 --- a/ceph_deploy/util/decorators.py +++ b/ceph_deploy/util/decorators.py @@ -1,5 +1,4 @@ import logging -import os import sys import traceback from functools import wraps diff --git a/scripts/ceph-deploy b/scripts/ceph-deploy index cc8dd62..5e2d153 100755 --- a/scripts/ceph-deploy +++ b/scripts/ceph-deploy @@ -18,4 +18,18 @@ elif os.path.exists('/usr/lib/python2.6/site-packages/ceph_deploy'): from ceph_deploy.cli import main if __name__ == '__main__': - sys.exit(main()) + try: + sys.exit(main()) + finally: + # This block is crucial to avoid having issues with + # Python spitting non-sense thread exceptions. We have already + # handled what we could, so close stderr and stdout. + if not os.environ.get('CEPH_DEPLOY_TEST'): + try: + sys.stdout.close() + except: + pass + try: + sys.stderr.close() + except: + pass -- 2.47.3