I've read several threads here on SO and the python docs on the SystemExit exception. This thread is not intended to be a duplicate as i did not find the answer in the similar threads.
Does both calling sys.exit() and raising SystemExit do cleanups ? I know sys.exit calls SystemExit, but if you just raise the SystemExit exception, does it do any cleanups for you ? The official python doc wasnt very clear on that. The reason im asking is because a colleague of mine thought that SystemExit was more clear to write in the code and you dont need to import the sys module..but just raising the exception im not sure that any cleanups are being done compared to calling sys.exit which does cleanup before it calls SystemExit from what i know.
Per the Python 2 docs for atexit, it appears that sys.exit and SystemExit will both result in normal cleanup. os._exit will not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With