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
This commit is contained in:
Brano Zarnovican 2015-11-20 11:06:08 +01:00 committed by Matt Clay
parent 079948eef0
commit 9fd52ac40e

View file

@ -199,6 +199,12 @@ if __name__ == '__main__':
notice("Module complete (%s)"%os.getpid()) notice("Module complete (%s)"%os.getpid())
sys.exit(0) 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: except Exception:
e = get_exception() e = get_exception()
notice("error: %s"%(e)) notice("error: %s"%(e))