mirror of https://github.com/python/cpython
Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
This commit is contained in:
parent
7db964d5aa
commit
546885ea4e
|
@ -1263,20 +1263,23 @@ class Logger(Filterer):
|
|||
"""
|
||||
Add the specified handler to this logger.
|
||||
"""
|
||||
_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()
|
||||
_acquireLock()
|
||||
try:
|
||||
if hdlr in self.handlers:
|
||||
self.handlers.remove(hdlr)
|
||||
finally:
|
||||
hdlr.release()
|
||||
_releaseLock()
|
||||
|
||||
def callHandlers(self, record):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue