Python program termination and exception catching

Jason Swails jason.swails at
Sun Apr 10 16:05:09 EDT 2011

On Sun, Apr 10, 2011 at 12:34 PM, Laszlo Nagy <gandalf at> wrote:

>  2011.04.10. 21:25 keltezéssel, Jason Swails írta:
> Hello everyone,
> This may sound like a bit of a strange desire, but I want to change the
> way in which a python program quits if an exception is not caught.  The
> program has many different classes of exceptions (for clarity purposes), and
> they're raised whenever something goes wrong.  Most I want to be fatal, but
> others I'd want to catch and deal with.
> Well, the application quits when all of it threads are ended. Do you want
> to catch those exception only in the last threads? Or do you want to do it
> in all threads? Or just the main thread?

The problem here is that the threads in this case are MPI threads, not
threads spawned during execution. (mpi4py).  I want exceptions to be fatal
as they normally are, but it *must* call MPI's Abort function instead of
just dying, because that will strand the rest of the processes and cause an
infinite hang if there are any subsequent communication attempts.

Hopefully this explains it more clearly?


Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list