try except question - serious foo bar question, and pulling my hair out :-)
gagsl-py2 at yahoo.com.ar
Tue Feb 24 09:52:14 EST 2009
En Tue, 24 Feb 2009 11:09:44 -0200, Laszlo Nagy <gandalf at shopzeus.com>
>> It seems impossible to me. The while loop should only exit if
>> stop_requested becomes set, OR if an exception is raised. However, all
>> exceptions are cought and logged. But there are no exceptions logged.
>> And stop_requested is NOT SET. (see the last line in the log).
>> What is happening here?
> It was a bad assumption. Not all exceptions are subclasses of
> "Exception". In this case, an inner call raised SystemExit(0).
Glad to see you finally found what was happening!
> So be aware. Don't think that this will catch all exceptions:
> except Exception,e:
> Use this instead:
> import sys
> e = sys.exc_value
Only at the outermost block on your code, if ever... The fact that some
exceptions don't inherit from Exception is on purpose -- usually you
*dont* want to catch (and swallow) SystemExit (nor KeyboardInterrupt, and
a few more I think)
More information about the Python-list