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 vinay.sajip
Recipients benspiller, vinay.sajip
Date 2019-06-20.16:49:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561049382.13.0.0785419189522.issue35185@roundup.psfhosted.org>
In-reply-to
Content
> 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).
History
Date User Action Args
2019-06-20 16:49:42vinay.sajipsetrecipients: + vinay.sajip, benspiller
2019-06-20 16:49:42vinay.sajipsetmessageid: <1561049382.13.0.0785419189522.issue35185@roundup.psfhosted.org>
2019-06-20 16:49:42vinay.sajiplinkissue35185 messages
2019-06-20 16:49:41vinay.sajipcreate