This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aronacher
Recipients aronacher, vinay.sajip
Date 2010-09-25.13:27:30
SpamBayes Score 4.0212527e-08
Marked as misclassified No
Message-id <1285421253.55.0.777992318976.issue9945@psf.upfronthosting.co.za>
In-reply-to
Content
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.
        """
        _acquireLock()
        try:
            if hdlr not in self.handlers:
                self.handlers.append(hdlr)
        finally:
            _releaseLock()

    def removeHandler(self, hdlr):
        """
        Remove the specified handler from this logger.
        """
        _acquireLock()
        try:
            if hdlr in self.handlers:
                self.handlers.remove(hdlr)
        finally:
            _releaseLock()

I suppose in 3.x there might be something similar.
History
Date User Action Args
2010-09-25 13:27:33aronachersetrecipients: + aronacher, vinay.sajip
2010-09-25 13:27:33aronachersetmessageid: <1285421253.55.0.777992318976.issue9945@psf.upfronthosting.co.za>
2010-09-25 13:27:31aronacherlinkissue9945 messages
2010-09-25 13:27:30aronachercreate