[issue9945] Improper locking in logging

2010-09-27 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Just to be sure: this does not apply to 3.1?

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9945
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9945] Improper locking in logging

2010-09-27 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

Good call, Éric - fix backported into release31-maint (r85045).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9945
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9945] Improper locking in logging

2010-09-25 Thread Armin Ronacher

New submission from Armin Ronacher armin.ronac...@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.

_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.

--
assignee: vinay.sajip
components: Library (Lib)
messages: 117364
nosy: aronacher, vinay.sajip
priority: normal
severity: normal
status: open
title: Improper locking in logging
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9945
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9945] Improper locking in logging

2010-09-25 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

Fix checked into py3k and release27-maint branches, r85012. Thanks!

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9945
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com