[Python-Dev] To run all exit handlers or not?

Guido van Rossum gvanrossum at gmail.com
Wed Oct 27 17:58:07 CEST 2004

On Wed, 27 Oct 2004 09:50:46 -0500, Skip Montanaro <skip at pobox.com> wrote:
> The current behavior of the atexit module is that if any of the exit
> handlers raises an exception the remaining handlers are not run.  Greg
> Chapman posted a bug report about this:
>     http://www.python.org/sf/1052242
> Greg proposed catching any exceptions and continuing so that all exit
> handlers at least have a chance to run and Raymond agrees with him.  I
> attached a patch to the ticket to add a flag to determine the behavior on
> the principle that atexit has been around long enough that someone out there
> probably relies on the early exit behavior.  This is the old Python chestnut
> of using a flag to preserve existing behavior as the default while allowing
> users to set the flag to get the new behavior.
> I'm happy to go either way, but thought perhaps a quick poll of the troops
> might be in order, hence this note.

If I were a user of the atexit module and aware of this behavior, I'd
consider it a bug write my atexit handler to avoid ever raising an
exception, because I didn't want to jeopardize other atexit handlers.
So I think preserving backwards-compatible behavior is unnecessary.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list