summaryrefslogtreecommitdiffstats
path: root/Doc/library/multiprocessing.rst
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-01-25 03:36:13 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-01-25 03:36:13 (GMT)
commitb5a4b0abed4fe0e3948352c4167efe4dca21cbed (patch)
treed3aae2d55978b4a3e526b83f6f530b24d3bf9c5a /Doc/library/multiprocessing.rst
parent10085c656f864763237e30194d61041cadc0143b (diff)
downloadcpython-b5a4b0abed4fe0e3948352c4167efe4dca21cbed.zip
cpython-b5a4b0abed4fe0e3948352c4167efe4dca21cbed.tar.gz
cpython-b5a4b0abed4fe0e3948352c4167efe4dca21cbed.tar.bz2
Properly document multiprocessing's logging support, resolve outstanding issues with the custom levels
Diffstat (limited to 'Doc/library/multiprocessing.rst')
-rw-r--r--Doc/library/multiprocessing.rst58
1 files changed, 51 insertions, 7 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index ee92a7c..3d66d14 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -1859,30 +1859,74 @@ handler type) for messages from different processes to get mixed up.
Returns the logger used by :mod:`multiprocessing`. If necessary, a new one
will be created.
- When first created the logger has level :data:`logging.NOTSET` and has a
- handler which sends output to :data:`sys.stderr` using format
- ``'[%(levelname)s/%(processName)s] %(message)s'``. (The logger allows use of
- the non-standard ``'%(processName)s'`` format.) Message sent to this logger
- will not by default propagate to the root logger.
+ When first created the logger has level :data:`logging.NOTSET` and no
+ default handler. Messages sent to this logger will not by default propagate
+ to the root logger.
Note that on Windows child processes will only inherit the level of the
parent process's logger -- any other customization of the logger will not be
inherited.
+.. currentmodule:: multiprocessing
+.. function:: log_to_stderr()
+
+ This function performs a call to :func:`get_logger` but in addition to
+ returning the logger created by get_logger, it adds a handler which sends
+ output to :data:`sys.stderr` using format
+ ``'[%(levelname)s/%(processName)s] %(message)s'``.
+
Below is an example session with logging turned on::
>>> import multiprocessing, logging
- >>> logger = multiprocessing.get_logger()
+ >>> logger = multiprocessing.log_to_stderr()
>>> logger.setLevel(logging.INFO)
>>> logger.warning('doomed')
[WARNING/MainProcess] doomed
>>> m = multiprocessing.Manager()
[INFO/SyncManager-1] child process calling self.run()
- [INFO/SyncManager-1] manager bound to '\\\\.\\pipe\\pyc-2776-0-lj0tfa'
+ [INFO/SyncManager-1] created temp directory /.../pymp-Wh47O_
+ [INFO/SyncManager-1] manager serving at '/.../listener-lWsERs'
>>> del m
[INFO/MainProcess] sending shutdown message to manager
[INFO/SyncManager-1] manager exiting with exitcode 0
+In addition to having these two logging functions, the multiprocessing also
+exposes two additional logging level attributes. These are :const:`SUBWARNING`
+and :const:`SUBDEBUG`. The table below illustrates where theses fit in the
+normal level hierarchy.
+
++----------------+----------------+
+| Level | Numeric value |
++================+================+
+| ``SUBWARNING`` | 25 |
++----------------+----------------+
+| ``SUBDEBUG`` | 5 |
++----------------+----------------+
+
+For a full table of logging levels, see the :mod:`logging` module.
+
+These additional logging levels are used primarily for certain debug messages
+within the multiprocessing module. Below is the same example as above, except
+with :const:`SUBDEBUG` enabled::
+
+ >>> import multiprocessing, logging
+ >>> logger = multiprocessing.log_to_stderr()
+ >>> logger.setLevel(multiprocessing.SUBDEBUG)
+ >>> logger.warning('doomed')
+ [WARNING/MainProcess] doomed
+ >>> m = multiprocessing.Manager()
+ [INFO/SyncManager-1] child process calling self.run()
+ [INFO/SyncManager-1] created temp directory /.../pymp-djGBXN
+ [INFO/SyncManager-1] manager serving at '/.../pymp-djGBXN/listener-knBYGe'
+ >>> del m
+ [SUBDEBUG/MainProcess] finalizer calling ...
+ [INFO/MainProcess] sending shutdown message to manager
+ [DEBUG/SyncManager-1] manager received shutdown message
+ [SUBDEBUG/SyncManager-1] calling <Finalize object, callback=unlink, ...
+ [SUBDEBUG/SyncManager-1] finalizer calling <built-in function unlink> ...
+ [SUBDEBUG/SyncManager-1] calling <Finalize object, dead>
+ [SUBDEBUG/SyncManager-1] finalizer calling <function rmtree at 0x5aa730> ...
+ [INFO/SyncManager-1] manager exiting with exitcode 0
The :mod:`multiprocessing.dummy` module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~