summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-25 17:42:36 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-25 17:42:36 (GMT)
commit546885ea4e3d1360bfc43d3890497aa91180d98d (patch)
tree76ed95fd3584e4f212ad02f8b8d80d28a0394b73
parent7db964d5aaf6a5a17e90c5d4da393476ae53c363 (diff)
downloadcpython-546885ea4e3d1360bfc43d3890497aa91180d98d.zip
cpython-546885ea4e3d1360bfc43d3890497aa91180d98d.tar.gz
cpython-546885ea4e3d1360bfc43d3890497aa91180d98d.tar.bz2
Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
-rw-r--r--Lib/logging/__init__.py19
-rw-r--r--Misc/NEWS2
2 files changed, 13 insertions, 8 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index c8e5ac2..e1dbbc0 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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):
"""
diff --git a/Misc/NEWS b/Misc/NEWS
index 77adf82..e6acb85 100644
--- 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.