[issue24645] logging.handlers.QueueHandler should not lock when handling a record

Vinay Sajip report at bugs.python.org
Fri Jul 17 02:32:42 CEST 2015


Vinay Sajip added the comment:

I agree the lock could be seen as redundant as there are no shared data structures used by the current implementation of the enqueue and prepare methods (which are called after the lock is acquired), but users could potentially override those methods in subclasses in ways that require locking to be thread-safe. Currently, people overriding emit() [or code called from there] know that any state they manipulate there is protected by the handler lock - and this would not be the case if I implemented your suggestion. It could certainly break subclasses of QueueHandler which are out there in the wild.

Note that the reference to locking is there in the Handler.handle docstring - https://docs.python.org/library/logging.html#logging.Handler.handle - so changing it would change the contract which is documented.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24645>
_______________________________________


More information about the Python-bugs-list mailing list