GUI application death catcher?

F. GEIGER fgeiger at datec.at
Thu Feb 19 04:00:30 EST 2004


Use PyChecker.
Write *extensive* unit tests, as Peter said.
Use sys.excepthook, as Josiah said.
Use the logging module.

It's unlikely that a non-GUI Python app or a Tkinter-GUI Python app crashes
the way that Windows wants to phone home to tell that M$. However, it's more
likely if you use wxPython as your GUI binding. But then you didn't do any
thorough tests.

HTH
Franz GEIGER

"Douglas Alan" <nessus at mit.edu> schrieb im Newsbeitrag
news:lcisi4ezli.fsf at gaffa.mit.edu...
> I'm writing a GUI app in Python that will be used on the International
> Space Station.  I'd like for the app to be as robust as possible and,
> consequently, if it crashes, for there to be a log file written and a
> coherent error message displayed to the astronaut.
>
> My original approach to this was to write an in-process handler in
> Python that would catch all uncaught exceptions and log the error to a
> file and then hand-hold the user.  This turned out to be a bit hairy
> because of all the additional possible errors that might happen while
> handling the original error, but I made a decent stab at it.
> Unfortunately, I find that as I keep working on the program, I often
> break the error handler by breaking some utility code that the error
> handler uses.  This isn't so good, so it's back to the drawing board a
> bit.
>
> One approach I might take now is to maintain duplicate utility
> libraries -- one for the error handler and one for the rest of the
> code.  That way I lessen the risk of breaking the error handler when I
> break the rest of the program.  Another approach, which is what I am
> leaning towards at the moment, would be to have the error handler be a
> completely separate process that monitors the application and takes
> over if and when the application fails.  I would like to write this in
> Python, of course, but then I have the worry of what happens if the
> Python installation gets bit rot, or something, and the monitoring
> program consequently won't run properly.  So, now I'm thinking that a
> completely stand-alone, statically linked executable would be best for
> this particular task.
>
> But I'm really not in the mood at the moment to write a Windows C++
> GUI app.  (Oh, did I mention that unfortunately this is going to run
> on a Windows 2000 machine?)  I'm figuring that such programs must
> already exist, since there must be a lot of demand for them.  In fact,
> it seems that when using Windows, I often see pop-up dialogs about how
> some program or another crashed and would I like to send a report off
> to M$?  I'd like the same thing for my app, only for it to send a
> report off to me, rather than M$.  Does anyone know of a preexisting
> (preferably freeware) utility that does what I want?
>
> |>oug





More information about the Python-list mailing list