Exit python properly -


i knew sys.exit() raises exit exception, when run knew wouldn't exit:

in [25]: try:    ....:     sys.exit()    ....: except:    ....:     print "oops"    ....:      oops 

but thought os._exit() meant exit using c call, it's causing exception:

in [28]: try:    ....:     os._exit()    ....: except:    ....:     print "oops"    ....:      oops 

is there way of doing without killing pid?

don't use except without exception class, sys.exit work fine without triggering exception handling:

>>> import sys >>> try: ...     sys.exit() ... except exception: ...     print 'oops' ...  $  

there other exceptions triggered plain except clause (and in general shouldn't), keyboardinterrupt.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -