A Python surprise: exiting is an exceptionOnce upon a time I wrote a program to scan incoming mail messages during the SMTP conversation for signs of spam. Because this was running as part of our mailer, reliability was very important; unhandled errors could cause us to lose mail. As part of reliability, I decided I wanted to catch any unhandled exception (which would normally abort the program with a backtrace), log the backtrace, save a copy of the message that caused the bug, and so on. So I wrote code that went like this:
The mail checking routine told the mailer whether to accept or reject
the message through the program's exit status code, so the routine
calls Then I actually ran this code, and the first time through it dutifully
spewed a backtrace into the logs about the code raising an unhandled
exception called Naievely (without paying attention to the documentation for the
sys module) I had
expected Unless, of course, you accidentally catch (This is another example of why
broad |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |