summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
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)
commit32fb6a81f992d86bb4c227912602c224dbbc7d7f (patch)
tree04b3f666c0b3d5caf3b803f4edf829bd71684b0a /Lib/logging/__init__.py
parentfda2106ac2f73d3b0a50196ffb8b01b6eafd99ff (diff)
downloadcpython-32fb6a81f992d86bb4c227912602c224dbbc7d7f.zip
cpython-32fb6a81f992d86bb4c227912602c224dbbc7d7f.tar.gz
cpython-32fb6a81f992d86bb4c227912602c224dbbc7d7f.tar.bz2
Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 4c3dd15..79ec9ef 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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):
"""