From 6887c92b1e1564f740df1b5c349f69f33163f4fe Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 4 Aug 2004 08:29:14 +0000 Subject: Close handlers and tidy up loggers by removing closed handlers - to avoid problems when run twice (SF #1002537) --- Lib/test/test_logging.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 57f201a..64ca571 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -411,7 +411,7 @@ def test_main_inner(): #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 - hdlr = logging.handlers.SocketHandler('localhost', + shdlr = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) #Configure the logger for logrecv so events do not propagate beyond it. @@ -437,10 +437,10 @@ def test_main_inner(): try: banner("log_test0", "begin") - rootLogger.addHandler(hdlr) + rootLogger.addHandler(shdlr) test0() - hdlr.close() - rootLogger.removeHandler(hdlr) + shdlr.close() + rootLogger.removeHandler(shdlr) banner("log_test0", "end") @@ -463,10 +463,16 @@ def test_main_inner(): thread.join() banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) - sockhdlr.close() sockOut.close() + sockLogger.removeHandler(sockhdlr) + sockhdlr.close() banner("logrecv output", "end") sys.stdout.flush() + try: + hdlr.close() + except: + pass + rootLogger.removeHandler(hdlr) def test_main(): import locale -- cgit v0.12