summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2012-04-15 11:41:32 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2012-04-15 11:41:32 (GMT)
commit69c635266ec20945142d6fb3beb2555769fed1ad (patch)
tree60080194a41ebb0a5b6bd87e6e2be55d706d6a0b /Doc
parentc014df7edf9d2358f80b783f4556a117a41924c0 (diff)
downloadcpython-69c635266ec20945142d6fb3beb2555769fed1ad.zip
cpython-69c635266ec20945142d6fb3beb2555769fed1ad.tar.gz
cpython-69c635266ec20945142d6fb3beb2555769fed1ad.tar.bz2
Issue #10576: Add a progress callback to gcmodule
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/gc.rst39
1 files changed, 37 insertions, 2 deletions
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
index 0281bb7..da78aa4 100644
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -153,8 +153,8 @@ The :mod:`gc` module provides the following functions:
.. versionadded:: 3.1
-The following variable is provided for read-only access (you can mutate its
-value but should not rebind it):
+The following variables are provided for read-only access (you can mutate the
+values but should not rebind them):
.. data:: garbage
@@ -183,6 +183,41 @@ value but should not rebind it):
:const:`DEBUG_UNCOLLECTABLE` is set, in addition all uncollectable objects
are printed.
+.. data:: callbacks
+
+ A list of callbacks that will be invoked by the garbage collector before and
+ after collection. The callbacks will be called with two arguments,
+ :arg:`phase` and :arg:`info`.
+
+ :arg:`phase` can one of two values:
+
+ "start": The garbage collection is about to start.
+
+ "stop": The garbage collection has finished.
+
+ :arg:`info` provides more information for the callback. The following
+ keys are currently defined:
+
+ "generation": The oldest generation being collected.
+
+ "collected": When :arg:`phase` is "stop", the number of objects
+ successfully collected.
+
+ "uncollectable": when :arg:`phase` is "stop", the number of objects
+ that could not be collected and were put in :data:`garbage`.
+
+ Applications can add their own callbacks to this list. The primary
+ use cases are:
+
+ Gathering statistics about garbage collection, such as how often
+ various generations are collected, and how long the collection
+ takes.
+
+ Allowing applications to identify and clear their own uncollectable
+ types when they appear in :data:`garbage`.
+
+ .. versionadded:: 3.3
+
The following constants are provided for use with :func:`set_debug`: