diff options
author | Collin Winter <collinw@gmail.com> | 2007-03-21 02:57:17 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-03-21 02:57:17 (GMT) |
commit | 670e6921349dd408b6958a0c5d3b1486725f9beb (patch) | |
tree | 719d6b0e5348693a2d985dfabc5e9160f7f79108 /Doc | |
parent | 450ee81b227b093eeb0b7a933fe6ddc6dc768d4a (diff) | |
download | cpython-670e6921349dd408b6958a0c5d3b1486725f9beb.zip cpython-670e6921349dd408b6958a0c5d3b1486725f9beb.tar.gz cpython-670e6921349dd408b6958a0c5d3b1486725f9beb.tar.bz2 |
Patch #1680961: remove sys.exitfunc and replace it with a private C API. Also, reimplement atexit in C so it can take advantage of this private API.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libatexit.tex | 36 | ||||
-rw-r--r-- | Doc/lib/libsys.tex | 13 |
2 files changed, 17 insertions, 32 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} diff --git a/Doc/lib/libsys.tex b/Doc/lib/libsys.tex index 7a8859b..ac161d9 100644 --- a/Doc/lib/libsys.tex +++ b/Doc/lib/libsys.tex @@ -218,19 +218,6 @@ It is always available. program when an error occurs. \end{funcdesc} -\begin{datadesc}{exitfunc} - This value is not actually defined by the module, but can be set by - the user (or by a program) to specify a clean-up action at program - exit. When set, it should be a parameterless function. This - function will be called when the interpreter exits. Only one - function may be installed in this way; to allow multiple functions - which will be called at termination, use the \refmodule{atexit} - module. \note{The exit function is not called when the program is - killed by a signal, when a Python fatal internal error is detected, - or when \code{os._exit()} is called.} - \deprecated{2.4}{Use \refmodule{atexit} instead.} -\end{datadesc} - \begin{funcdesc}{getcheckinterval}{} Return the interpreter's ``check interval''; see \function{setcheckinterval()}. |