]> granicus.if.org Git - python/commitdiff
- Issue #15233: Python now guarantees that callables registered with
authorLarry Hastings <larry@hastings.org>
Sun, 15 Jul 2012 01:20:37 +0000 (18:20 -0700)
committerLarry Hastings <larry@hastings.org>
Sun, 15 Jul 2012 01:20:37 +0000 (18:20 -0700)
  the atexit module will be called in a deterministic order.

Doc/library/atexit.rst
Misc/NEWS

index 3d5c0147622011985c97483d000c2ce4f20dd75d..2e22cab1cd87794f0731ee3d4af6eac29728f10c 100644 (file)
@@ -9,13 +9,14 @@
 
 The :mod:`atexit` module defines functions to register and unregister cleanup
 functions.  Functions thus registered are automatically executed upon normal
-interpreter termination.  The order in which the functions are called is not
-defined; if you have cleanup operations that depend on each other, you should
-wrap them in a function and register that one.  This keeps :mod:`atexit` simple.
-
-Note: the functions registered via this module are not called when the program
-is killed by a signal not handled by Python, when a Python fatal internal error
-is detected, or when :func:`os._exit` is called.
+interpreter termination.  :mod:`atexit` runs these functions in the *reverse*
+order in which they were registered; if you register ``A``, ``B``, and ``C``,
+at interpreter termination time they will be run in the order ``C``, ``B``,
+``A``.
+
+**Note:** The functions registered via this module are not called when the
+program is killed by a signal not handled by Python, when a Python fatal
+internal error is detected, or when :func:`os._exit` is called.
 
 
 .. function:: register(func, *args, **kargs)
index c99cbd27b79fdd124d96d52d871b7a60b8493200..f00f2bb142610d3d17d11f41c09ac1e4673c6bd6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #15233: Python now guarantees that callables registered with
+  the atexit module will be called in a deterministic order.
+
 - Issue #15238: shutil.copystat now copies Linux "extended attributes".
 
 - Issue #15230: runpy.run_path now correctly sets __package__ as described