]> granicus.if.org Git - python/commitdiff
Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 25 Sep 2010 17:42:36 +0000 (17:42 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 25 Sep 2010 17:42:36 +0000 (17:42 +0000)
Lib/logging/__init__.py
Misc/NEWS

index c8e5ac290c1c552011d30530b0a2b6c0cbb504f5..e1dbbc03aa7c3f9ccbfc4ed1bfe20d03d0c85c8e 100644 (file)
@@ -1263,20 +1263,23 @@ class Logger(Filterer):
         """
         Add the specified handler to this logger.
         """
-        if not (hdlr in self.handlers):
-            self.handlers.append(hdlr)
+        _acquireLock()
+        try:
+            if not (hdlr in self.handlers):
+                self.handlers.append(hdlr)
+        finally:
+            _releaseLock()
 
     def removeHandler(self, hdlr):
         """
         Remove the specified handler from this logger.
         """
-        if hdlr in self.handlers:
-            #hdlr.close()
-            hdlr.acquire()
-            try:
+        _acquireLock()
+        try:
+            if hdlr in self.handlers:
                 self.handlers.remove(hdlr)
-            finally:
-                hdlr.release()
+        finally:
+            _releaseLock()
 
     def callHandlers(self, record):
         """
index 77adf82beba1573f587b21cab5110b092423fa7f..e6acb856d9aa8022c2c0094b85a8fecd0d72b3ca 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
+
 - Issue #9936: Fixed executable lines' search in the trace module.
 
 - Issue #9928: Properly initialize the types exported by the bz2 module.