diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-01-29 20:10:38 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-01-29 20:10:38 (GMT) |
commit | 5b1e003da8f79a9b8d81ab498cffc49266aa1ac4 (patch) | |
tree | 746171d99ecce6dcbbc991f473ddf16c7e4905c9 | |
parent | f684888b1e9c75b344e72fc9b49a940d6f461aee (diff) | |
download | cpython-5b1e003da8f79a9b8d81ab498cffc49266aa1ac4.zip cpython-5b1e003da8f79a9b8d81ab498cffc49266aa1ac4.tar.gz cpython-5b1e003da8f79a9b8d81ab498cffc49266aa1ac4.tar.bz2 |
Try a number of ports, in case 9020 is already in use.
-rw-r--r-- | Lib/test/test_logging.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 54d17a3..16dd93c 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -565,11 +565,23 @@ def test_main_inner(): hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) + # Find an unused port number + port = logging.handlers.DEFAULT_TCP_LOGGING_PORT + while port < logging.handlers.DEFAULT_TCP_LOGGING_PORT+100: + try: + tcpserver = LogRecordSocketReceiver(port=port) + except socket.error: + port += 1 + else: + break + else: + raise ImportError, "Could not find unused port" + + #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #The handler will only be added to the rootLogger for some of the tests - shdlr = logging.handlers.SocketHandler('localhost', - logging.handlers.DEFAULT_TCP_LOGGING_PORT) + shdlr = logging.handlers.SocketHandler('localhost', port) #Configure the logger for logrecv so events do not propagate beyond it. #The sockLogger output is buffered in memory until the end of the test, @@ -585,7 +597,6 @@ def test_main_inner(): #Set up servers threads = [] - tcpserver = LogRecordSocketReceiver() #sys.stdout.write("About to start TCP server...\n") threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) |