[New-bugs-announce] [issue9945] Improper locking in logging
report at bugs.python.org
Sat Sep 25 15:27:33 CEST 2010
New submission from Armin Ronacher <armin.ronacher at active-4.com>:
I found a a useless lock acquiring in the 27 maintenance branch in logging and a missing one as well:
Logger.removeHandler() locks around a handler lock, however the code executed in this lock is not depending on anything of that lock. However there is a race condition when two pieces of code try to remove the same handler at the same time because between the if and the remove() no locking takes place.
I would recommend this instead (and also add locking to the addHandler):
def addHandler(self, hdlr):
Add the specified handler to this logger.
if hdlr not in self.handlers:
def removeHandler(self, hdlr):
Remove the specified handler from this logger.
if hdlr in self.handlers:
I suppose in 3.x there might be something similar.
components: Library (Lib)
nosy: aronacher, vinay.sajip
title: Improper locking in logging
versions: Python 2.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce