]> granicus.if.org Git - python/commitdiff
Issue #8576: logging updated to remove usage of find_unused_port().
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 3 May 2010 15:11:53 +0000 (15:11 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 3 May 2010 15:11:53 +0000 (15:11 +0000)
Lib/logging/config.py
Lib/test/test_logging.py
Misc/NEWS

index 4f55c53ead16e408a033b913a12a101cae6d3be3..07b9d1a8342ac6b56d53daa48033dd34c87e5f18 100644 (file)
@@ -873,6 +873,8 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
         def run(self):
             server = self.rcvr(port=self.port, handler=self.hdlr,
                                ready=self.ready)
+            if self.port == 0:
+                self.port = server.server_address[1]
             self.ready.set()
             global _listener
             logging._acquireLock()
index 0211f560747192a67593eb22a5e81723f4173ba1..ed17d15f2ee1ddde3a7521dd5ed9591959bd1883 100644 (file)
@@ -38,8 +38,7 @@ from SocketServer import ThreadingTCPServer, StreamRequestHandler
 import struct
 import sys
 import tempfile
-from test.test_support import captured_stdout, run_with_locale, run_unittest,\
-     find_unused_port
+from test.test_support import captured_stdout, run_with_locale, run_unittest
 import textwrap
 import unittest
 import warnings
@@ -1664,10 +1663,12 @@ class ConfigDictTest(BaseTest):
 
     @unittest.skipUnless(threading, 'listen() needs threading to work')
     def setup_via_listener(self, text):
-        port = find_unused_port()
-        t = logging.config.listen(port)
+        # Ask for a randomly assigned port (by using port 0)
+        t = logging.config.listen(0)
         t.start()
         t.ready.wait()
+        # Now get the port allocated
+        port = t.port
         t.ready.clear()
         try:
             sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
index f4f4d2fb613dcdd48e93da198fc722f3cb68ada2..e024d60a9b07d72e9ee81f0bfb4e497db7b1023f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8576: logging updated to remove usage of find_unused_port().
+
 - Issue #4687: Fix accuracy of garbage collection runtimes displayed with
   gc.DEBUG_STATS.