diff options
-rw-r--r-- | Lib/logging/__init__.py | 3 | ||||
-rw-r--r-- | Lib/test/test_logging.py | 8 |
2 files changed, 6 insertions, 5 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 5a0b0f5..9fa8797 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -671,7 +671,8 @@ class Handler(Filterer): #get the module data lock, as we're updating a shared structure. _acquireLock() try: #unlikely to raise an exception, but you never know... - del _handlers[self] + if _handlers.has_key(self): + del _handlers[self] _handlerList.remove(self) finally: _releaseLock() diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 799f059..bcebc83 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -99,14 +99,12 @@ class LogRecordSocketReceiver(ThreadingTCPServer): self.timeout = 1 def serve_until_stopped(self): - abort = 0 - while not abort: + while not self.abort: rd, wr, ex = select.select([self.socket.fileno()], [], [], self.timeout) if rd: self.handle_request() - abort = self.abort #notify the main thread that we're about to exit socketDataProcessed.set() # close the listen socket @@ -620,8 +618,10 @@ def test_main_inner(): finally: #wait for TCP receiver to terminate socketDataProcessed.wait() + # ensure the server dies + tcpserver.abort = 1 for thread in threads: - thread.join() + thread.join(2.0) banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) sockOut.close() |