try except question - serious foo bar question, and pulling my hair out :-)

Laszlo Nagy gandalf at shopzeus.com
Tue Feb 24 08:09:44 EST 2009


>
> 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). So be 
aware. Don't think that this will catch all exceptions:

try:
    ???
except Exception,e:
   do_with(e)


Use this instead:

import sys
try:
    ???
except:
   e = sys.exc_value
   do_with(e)


Thanks,

   Laszlo




More information about the Python-list mailing list