]> 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 4c3dd1539d89c34b94a7942c293e89197e49bf0d..79ec9ef7d592d7b1a484508164af13ba29491fc9 100644 (file)
@@ -1226,19 +1226,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.acquire()
-            try:
+        _acquireLock()
+        try:
+            if hdlr in self.handlers:
                 self.handlers.remove(hdlr)
-            finally:
-                hdlr.release()
+        finally:
+            _releaseLock()
 
     def hasHandlers(self):
         """
index 489d6a96735937c6223767ced18c944e0a6ea6e1..c84a8ef3c465106f5c1a5f2341bbb7c7f3539627 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -68,6 +68,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 #9790: Rework imports necessary for samefile and sameopenfile