From 9fd52ac40efd2575c9a437c870364c82d59454f5 Mon Sep 17 00:00:00 2001 From: Brano Zarnovican Date: Fri, 20 Nov 2015 11:06:08 +0100 Subject: [PATCH] Py2.4: SystemExit in async_wrapper is not an error - compatibility fix Prior to Python 2.5, SystemExit was a subclass of Exception. In Py2.4, this is causing extra error output on valid sys.exit(0). (Toshio) Call sys.exit from inside of the SystemExit exception handler so py2.4 and py2.5+ behaviour matches --- lib/ansible/modules/utilities/logic/async_wrapper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/utilities/logic/async_wrapper.py b/lib/ansible/modules/utilities/logic/async_wrapper.py index e0341aa8017..fd7699d17ac 100644 --- a/lib/ansible/modules/utilities/logic/async_wrapper.py +++ b/lib/ansible/modules/utilities/logic/async_wrapper.py @@ -199,6 +199,12 @@ if __name__ == '__main__': notice("Module complete (%s)"%os.getpid()) sys.exit(0) + except SystemExit: + # On python2.4, SystemExit is a subclass of Exception. + # This block makes python2.4 behave the same as python2.5+ + e = get_exception() + sys.exit(e.code) + except Exception: e = get_exception() notice("error: %s"%(e))