summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libatexit.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libatexit.tex')
-rw-r--r--Doc/lib/libatexit.tex36
1 files changed, 17 insertions, 19 deletions
diff --git a/Doc/lib/libatexit.tex b/Doc/lib/libatexit.tex
index 9798b57..04f1d49 100644
--- a/Doc/lib/libatexit.tex
+++ b/Doc/lib/libatexit.tex
@@ -1,32 +1,21 @@
\section{\module{atexit} ---
Exit handlers}
-\declaremodule{standard}{atexit}
+\declaremodule{builtin}{atexit}
\moduleauthor{Skip Montanaro}{skip@mojam.com}
\sectionauthor{Skip Montanaro}{skip@mojam.com}
\modulesynopsis{Register and execute cleanup functions.}
\versionadded{2.0}
-The \module{atexit} module defines a single function to register
-cleanup functions. Functions thus registered are automatically
-executed upon normal interpreter termination.
-Note: the functions registered via this module are not called when the program is killed by a
-signal, when a Python fatal internal error is detected, or when
-\function{os._exit()} is called.
+The \module{atexit} module defines functions to register and
+unregister cleanup functions. Functions thus registered are
+automatically executed upon normal interpreter termination.
-This is an alternate interface to the functionality provided by the
-\code{sys.exitfunc} variable.
-\withsubitem{(in sys)}{\ttindex{exitfunc}}
-
-Note: This module is unlikely to work correctly when used with other code
-that sets \code{sys.exitfunc}. In particular, other core Python modules are
-free to use \module{atexit} without the programmer's knowledge. Authors who
-use \code{sys.exitfunc} should convert their code to use
-\module{atexit} instead. The simplest way to convert code that sets
-\code{sys.exitfunc} is to import \module{atexit} and register the function
-that had been bound to \code{sys.exitfunc}.
+Note: the functions registered via this module are not called when
+the program is killed by a signal, when a Python fatal internal
+error is detected, or when \function{os._exit()} is called.
\begin{funcdesc}{register}{func\optional{, *args\optional{, **kargs}}}
Register \var{func} as a function to be executed at termination. Any
@@ -47,7 +36,16 @@ chance to run the last exception to be raised is re-raised.
\versionchanged[This function now returns \var{func} which makes it
possible to use it as a decorator without binding the
- original name to \code{None}]{2.6}
+ original name to \code{None}]{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{unregister}{func}
+Remove a function \var{func} from the list of functions to be run at
+interpreter-shutdown. After calling \function{unregister()},
+\var{func} is guaranteed not to be called when the interpreter
+shuts down.
+
+\versionadded{3.0}
\end{funcdesc}