[Python-checkins] r42246 - in python/trunk/Lib: logging/__init__.py test/test_logging.py

neal.norwitz python-checkins at python.org
Sun Feb 5 11:59:53 CET 2006


Author: neal.norwitz
Date: Sun Feb  5 09:21:08 2006
New Revision: 42246

Modified:
   python/trunk/Lib/logging/__init__.py
   python/trunk/Lib/test/test_logging.py
Log:
Get test_logging to not hang when running under regrtest.py -R ::

Not sure why/how _handlers/_handlerList is out of sync.  This could
indicate a deeper problem.

In test_logging, the only absolutely necessary change to get working
was tcpserver.abort = 1.  But we don't want to wait infinitely
to join the threads, so give a 2.0 second timeout.

There doesn't appear to be a need for a local abort variable
in serve_until_stopped, so just use the instance member.

Note the problem is only on HEAD, not in 2.4.



Modified: python/trunk/Lib/logging/__init__.py
==============================================================================
--- python/trunk/Lib/logging/__init__.py	(original)
+++ python/trunk/Lib/logging/__init__.py	Sun Feb  5 09:21:08 2006
@@ -671,7 +671,8 @@
         #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()

Modified: python/trunk/Lib/test/test_logging.py
==============================================================================
--- python/trunk/Lib/test/test_logging.py	(original)
+++ python/trunk/Lib/test/test_logging.py	Sun Feb  5 09:21:08 2006
@@ -99,14 +99,12 @@
         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 @@
     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()


More information about the Python-checkins mailing list