Python program termination and exception catching
benjamin.kaplan at case.edu
Sun Apr 10 22:12:34 CEST 2011
On Sun, Apr 10, 2011 at 4:05 PM, Jason Swails <jason.swails at gmail.com> wrote:
> On Sun, Apr 10, 2011 at 12:34 PM, Laszlo Nagy <gandalf at shopzeus.com> 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?
Is there any reason you can't just surround the top level stuff in a
try block? Assuming you have any structure at all to your program,
there should be a single function call or two that triggers all the
MPI stuff- just catch the exceptions up there.
> Jason M. Swails
> Quantum Theory Project,
> University of Florida
> Ph.D. Candidate
More information about the Python-list