os._exit vs. sys.exit
Bryan
nestleNOSPAM12 at comcast.net
Fri Jul 29 08:19:45 EDT 2005
"Peter Hansen" <peter at engcorp.com> wrote in message
news:u-SdnRAzQ9KHhnffRVn-gg at powergate.ca...
> Andrew Dalke wrote:
>> sys.exit() is identical to "raise SystemExit()". It raises a Python
>> exception which may be caught at a higher level in the program stack.
>
> And which *is* caught at the highest levels of threading.Thread objects
> (which Timer is based on). Exceptions raised (and caught or not) in a
> Thread do not have any effect on the main thread, and thus don't affect
> the interpreter as a whole.
>
> -Peter
Thanks for the clarifications. One more question, can I catch this
exception in my main thread and then do another sys.exit() to kill the whole
process?
Apparently sys.exit() allows the program to clean up resources and exit
gracefully, while os._exit() is rather abrupt.
Bryan
More information about the Python-list
mailing list