]> granicus.if.org Git - python/commitdiff
Issue #15233: Python now guarantees that callables registered with the atexit
authorCharles-François Natali <cf.natali@gmail.com>
Wed, 21 Aug 2013 16:25:00 +0000 (18:25 +0200)
committerCharles-François Natali <cf.natali@gmail.com>
Wed, 21 Aug 2013 16:25:00 +0000 (18:25 +0200)
module will be called in a deterministic order.

Doc/library/atexit.rst
Misc/NEWS

index 37d8d500ef1d4e8c9ff4a60835ff17de063f034e..0b5e121fe630cb6ea4d63d9de926db5d150faef2 100644 (file)
 
 The :mod:`atexit` module defines a single function to register 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.
 
 .. index:: single: exitfunc (in sys)
 
index 04317f8399936336c985f784f8869f30590afb42..83b5116dc41438fe1405c6c33c14d83ef8360819 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -32,6 +32,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 #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
   A pthread_atfork() child handler is used to seeded the PRNG with pid, time
   and some stack data.