Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/atexit.rst

    r2 r391  
    1 
    21:mod:`atexit` --- Exit handlers
    32===============================
     
    1110.. versionadded:: 2.0
    1211
     12**Source code:** :source:`Lib/atexit.py`
     13
     14--------------
     15
    1316The :mod:`atexit` module defines a single function to register cleanup
    1417functions.  Functions thus registered are automatically executed upon normal
    15 interpreter termination.
     18interpreter termination.  :mod:`atexit` runs these functions in the *reverse*
     19order in which they were registered; if you register ``A``, ``B``, and ``C``,
     20at interpreter termination time they will be run in the order ``C``, ``B``,
     21``A``.
    1622
    17 Note: the functions registered via this module are not called when the program
    18 is killed by a signal, when a Python fatal internal error is detected, or when
    19 :func:`os._exit` is called.
     23**Note:** The functions registered via this module are not called when the
     24program is killed by a signal not handled by Python, when a Python fatal
     25internal error is detected, or when :func:`os._exit` is called.
    2026
    2127.. index:: single: exitfunc (in sys)
    2228
    2329This is an alternate interface to the functionality provided by the
    24 ``sys.exitfunc`` variable.
     30:func:`sys.exitfunc` variable.
    2531
    2632Note: This module is unlikely to work correctly when used with other code that
     
    3642   Register *func* as a function to be executed at termination.  Any optional
    3743   arguments that are to be passed to *func* must be passed as arguments to
    38    :func:`register`.
     44   :func:`register`.  It is possible to register the same function and arguments
     45   more than once.
    3946
    4047   At normal program termination (for instance, if :func:`sys.exit` is called or
     
    5057
    5158   .. versionchanged:: 2.6
    52       This function now returns *func* which makes it possible to use it as a
    53       decorator without binding the original name to ``None``.
     59      This function now returns *func*, which makes it possible to use it as a
     60      decorator.
    5461
    5562
     
    7178
    7279   try:
    73        _count = int(open("/tmp/counter").read())
     80       _count = int(open("counter").read())
    7481   except IOError:
    7582       _count = 0
     
    8087
    8188   def savecounter():
    82        open("/tmp/counter", "w").write("%d" % _count)
     89       open("counter", "w").write("%d" % _count)
    8390
    8491   import atexit
     
    105112       print "You are now leaving the Python sector."
    106113
    107 This obviously only works with functions that don't take arguments.
    108 
     114This only works with functions that can be called without arguments.
Note: See TracChangeset for help on using the changeset viewer.