On Aug 2, 2005, at 12:31 AM, Phillip J. Eby wrote: > If you think that a KeyboardInterrupt is an error, then it's an > indication > that Python's documentation and the current exception class > hierarchy has > failed to educate you sufficiently, and that we *really* need to add a > class like ControlFlowException into the hierarchy to help make > sure that > other people don't end up sharing your misunderstanding. ;-)
No... KeyboardInterrupt (just like other asynchronous exceptions) really should be treated as a critical error. Doing anything other than killing your process off after receiving it is just inviting disaster. Because the exception can have occurred absolutely anywhere, it is unsuitable for normal use. Aborting a function between two arbitrary bytecodes and trying to continue operation is simply a recipe for disaster. For example, in threadable.py between line 200 "saved_state = self._release_save()" and 201 "try: # restore state no matter what (e.g., KeyboardInterrupt)" would be a bad place to hit control-c if you ever need to use that Condition again. This kind of problem is pervasive and unavoidable. If you want to do a clean shutdown on control-c, the only sane way is to install a custom signal handler that doesn't throw an asynchronous exception at you. There's a reason asynchronously killing off threads was deprecated in java. James _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com