summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-01-25 03:45:53 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-01-25 03:45:53 (GMT)
commit41faa543b66431ee5b8c79f70a40ef267615050b (patch)
tree66a269384bd0550e40d89c2ebffeef7cf1c237e8 /Lib
parentcddcf444b257478eb940c50c78eb86ef40eae16f (diff)
downloadcpython-41faa543b66431ee5b8c79f70a40ef267615050b.zip
cpython-41faa543b66431ee5b8c79f70a40ef267615050b.tar.gz
cpython-41faa543b66431ee5b8c79f70a40ef267615050b.tar.bz2
merge r68915 to py3k
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/__init__.py3
-rw-r--r--Lib/multiprocessing/util.py36
2 files changed, 26 insertions, 13 deletions
diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py
index aad4191..5a13742 100644
--- a/Lib/multiprocessing/__init__.py
+++ b/Lib/multiprocessing/__init__.py
@@ -48,7 +48,7 @@ __all__ = [
'allow_connection_pickling', 'BufferTooShort', 'TimeoutError',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition',
'Event', 'Queue', 'JoinableQueue', 'Pool', 'Value', 'Array',
- 'RawValue', 'RawArray'
+ 'RawValue', 'RawArray', 'SUBDEBUG', 'SUBWARNING',
]
__author__ = 'R. Oudkerk (r.m.oudkerk@gmail.com)'
@@ -61,6 +61,7 @@ import os
import sys
from multiprocessing.process import Process, current_process, active_children
+from multiprocessing.util import SUBDEBUG, SUBWARNING
#
# Exceptions
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py
index ac9d79e..b13f565 100644
--- a/Lib/multiprocessing/util.py
+++ b/Lib/multiprocessing/util.py
@@ -17,7 +17,8 @@ from multiprocessing.process import current_process, active_children
__all__ = [
'sub_debug', 'debug', 'info', 'sub_warning', 'get_logger',
'log_to_stderr', 'get_temp_dir', 'register_after_fork',
- 'is_exiting', 'Finalize', 'ForkAwareThreadLock', 'ForkAwareLocal'
+ 'is_exiting', 'Finalize', 'ForkAwareThreadLock', 'ForkAwareLocal',
+ 'SUBDEBUG', 'SUBWARNING',
]
#
@@ -57,19 +58,27 @@ def get_logger():
Returns logger used by multiprocessing
'''
global _logger
+ import logging, atexit
- if not _logger:
- import logging, atexit
+ logging._acquireLock()
+ try:
+ if not _logger:
- # XXX multiprocessing should cleanup before logging
- if hasattr(atexit, 'unregister'):
- atexit.unregister(_exit_function)
- atexit.register(_exit_function)
- else:
- atexit._exithandlers.remove((_exit_function, (), {}))
- atexit._exithandlers.append((_exit_function, (), {}))
+ _logger = logging.getLogger(LOGGER_NAME)
+ _logger.propagate = 0
+ logging.addLevelName(SUBDEBUG, 'SUBDEBUG')
+ logging.addLevelName(SUBWARNING, 'SUBWARNING')
+
+ # XXX multiprocessing should cleanup before logging
+ if hasattr(atexit, 'unregister'):
+ atexit.unregister(_exit_function)
+ atexit.register(_exit_function)
+ else:
+ atexit._exithandlers.remove((_exit_function, (), {}))
+ atexit._exithandlers.append((_exit_function, (), {}))
- _logger = logging.getLogger(LOGGER_NAME)
+ finally:
+ logging._releaseLock()
return _logger
@@ -79,14 +88,17 @@ def log_to_stderr(level=None):
'''
global _log_to_stderr
import logging
+
logger = get_logger()
formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
- if level is not None:
+
+ if level:
logger.setLevel(level)
_log_to_stderr = True
+ return _logger
#
# Function returning a temp directory which will be removed on exit