[Python-checkins] r85012 - in python/branches: py3k/Lib/logging/__init__.py py3k/Misc/NEWS release27-maint/Lib/logging/__init__.py release27-maint/Misc/NEWS

vinay.sajip python-checkins at python.org
Sat Sep 25 19:42:36 CEST 2010


Author: vinay.sajip
Date: Sat Sep 25 19:42:36 2010
New Revision: 85012

Log:
Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.

Modified:
   python/branches/py3k/Lib/logging/__init__.py
   python/branches/py3k/Misc/NEWS
   python/branches/release27-maint/Lib/logging/__init__.py
   python/branches/release27-maint/Misc/NEWS

Modified: python/branches/py3k/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k/Lib/logging/__init__.py	(original)
+++ python/branches/py3k/Lib/logging/__init__.py	Sat Sep 25 19:42:36 2010
@@ -1226,19 +1226,23 @@
         """
         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):
         """

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Sep 25 19:42:36 2010
@@ -68,6 +68,8 @@
 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

Modified: python/branches/release27-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release27-maint/Lib/logging/__init__.py	(original)
+++ python/branches/release27-maint/Lib/logging/__init__.py	Sat Sep 25 19:42:36 2010
@@ -1263,20 +1263,23 @@
         """
         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):
         """

Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS	(original)
+++ python/branches/release27-maint/Misc/NEWS	Sat Sep 25 19:42:36 2010
@@ -43,6 +43,8 @@
 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.


More information about the Python-checkins mailing list