diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2004-08-04 08:29:14 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2004-08-04 08:29:14 (GMT) |
commit | 6887c92b1e1564f740df1b5c349f69f33163f4fe (patch) | |
tree | 78527f73521a975e12edab1ade8e312e690eee71 | |
parent | 4189c643f8a631ec309ecf9cde79cf0ff2824a26 (diff) | |
download | cpython-6887c92b1e1564f740df1b5c349f69f33163f4fe.zip cpython-6887c92b1e1564f740df1b5c349f69f33163f4fe.tar.gz cpython-6887c92b1e1564f740df1b5c349f69f33163f4fe.tar.bz2 |
Close handlers and tidy up loggers by removing closed handlers - to avoid problems when run twice (SF #1002537)
-rw-r--r-- | Lib/test/test_logging.py | 16 |
1 files 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 |