The logging module errors out if the multiprocessing module is not finished loading when logging.log() is called.
This can happen, for example, if a custom import hook is defined that causes third-party code to execute when the multiprocessing module gets to an import statement. (autoinstall is an example of a package that defines such an import hook: http://pypi.python.org/pypi/autoinstall/0.1a2 )
Here is a stack trace of the issue in action:
File "/Users/chris_g4/dev/apple/WebKit-git/WebKitTools/Scripts/webkitpy/executive.py", line 118, in cpu_count
import multiprocessing
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/multiprocessing/__init__.py", line 60, in <module>
import os
File "/Users/chris_g4/dev/apple/WebKit-git/WebKitTools/Scripts/webkitpy/thirdparty/autoinstall.py", line 279, in find_module
_logger.debug("find_module(%s, path=%s)" % (fullname, path))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 1036, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 1164, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 1139, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 279, in __init__
self.processName = sys.modules['multiprocessing'].current_process().name
AttributeError: 'module' object has no attribute 'current_process'
Here is a possible fix (in logging/__init__.py):
if not logMultiprocessing:
self.processName = None
# "current_process" might not be defined if multiprocessing is
# not finished loading yet. This can happen, for example, if
# a custom import hook is defined that causes third-party code
# to execute when the multiprocessing module calls import.
- elif 'multiprocessing' not in sys.modules:
+ elif 'multiprocessing' not in sys.modules or \
+ 'current_process' not in dir(sys.modules['multiprocessing']):
self.processName = 'MainProcess'
else:
self.processName = sys.modules['multiprocessing'].current_process().name
if logProcesses and hasattr(os, 'getpid'):
self.process = os.getpid()
|