Commit a82addb5 authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 80712,81651 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80712 | vinay.sajip | 2010-05-03 10:11:53 -0500 (Mon, 03 May 2010) | 1 line

  Issue #8576: logging updated to remove usage of find_unused_port().
........
  r81651 | vinay.sajip | 2010-06-02 05:05:31 -0500 (Wed, 02 Jun 2010) | 1 line

  Logging: improved error reporting for BaseConfigurator.resolve().
........
parent 28df4df0
...@@ -386,15 +386,21 @@ class BaseConfigurator(object): ...@@ -386,15 +386,21 @@ class BaseConfigurator(object):
""" """
name = s.split('.') name = s.split('.')
used = name.pop(0) used = name.pop(0)
found = self.importer(used) try:
for frag in name: found = self.importer(used)
used += '.' + frag for frag in name:
try: used += '.' + frag
found = getattr(found, frag) try:
except AttributeError: found = getattr(found, frag)
self.importer(used) except AttributeError:
found = getattr(found, frag) self.importer(used)
return found found = getattr(found, frag)
return found
except ImportError:
e, tb = sys.exc_info()[1:]
v = ValueError('Cannot resolve %r: %s' % (s, e))
v.__cause__, v.__traceback__ = e, tb
raise v
def ext_convert(self, value): def ext_convert(self, value):
"""Default converter for the ext:// protocol.""" """Default converter for the ext:// protocol."""
...@@ -873,6 +879,8 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT): ...@@ -873,6 +879,8 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
def run(self): def run(self):
server = self.rcvr(port=self.port, handler=self.hdlr, server = self.rcvr(port=self.port, handler=self.hdlr,
ready=self.ready) ready=self.ready)
if self.port == 0:
self.port = server.server_address[1]
self.ready.set() self.ready.set()
global _listener global _listener
logging._acquireLock() logging._acquireLock()
......
...@@ -1670,6 +1670,8 @@ class ConfigDictTest(BaseTest): ...@@ -1670,6 +1670,8 @@ class ConfigDictTest(BaseTest):
t = logging.config.listen(port) t = logging.config.listen(port)
t.start() t.start()
t.ready.wait() t.ready.wait()
# Now get the port allocated
port = t.port
t.ready.clear() t.ready.clear()
try: try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment