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

> I'd definitely suggest we go for a solution that doesn't hit performance of 
> normal logging

I agree, but correctness is important. I'm tending to the following:

1. Introduce a lockCallHandling module-level variable, defaulting to False to 
maximise logging performance (and follow current behaviour) and settable to 
True for situations such as your example, where adding/removing handlers from 
threads is wanted.

2. In Logger.handle, add an extra check for lockCallHandling to decide whether 
to lock/release around callHandlers().

BTW a simple benchmark of performance of locking around callHanders vs. not 
locking, using a FileHandler and default StreamHandler, showed an average 
difference of ~ 480 usec per iteration (mean time of 47.310 secs unlocked vs. 
47.784 locked, for a million iterations of logger.debug() - a 1% increase).

> the second idea I suggested should do that

Yes, but the copying seems to make things slower, as suggested by the output of 
your script (in terms of the iteration counts in a fixed amount of time).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35185>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to