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 benspiller
Recipients benspiller, vinay.sajip
Date 2019-06-20.14:03:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561039414.42.0.528306300619.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 when you're not adding/removing things, being as that's the more common case. I guess that's the reason why callHandlers was originally implemented without grabbing the mutex, and we should probably keep it that way. Logging can be a performance-critical part of some applications and I feel more comfortable about the fix (and more confident it won't get vetoed :)) if we can avoid changing callHandlers(). 

You make a good point about ensuring the solution works for non-GIL python versions. I thought about it some more... correct me if I'm wrong but as far as I can see the second idea I suggested should do that, i.e.
- self.handlers.remove(hdlr)
+ newhandlers = list(self.handlers)
+ newhandlers.remove(hdlr)
+ self.handlers = hdlr

... which effectively changes the model so that the _value_ of the self.handlers list is immutable (only which list the self.handlers reference points to changes), so without relying on any GIL locking callHandlers will still see the old list or the new list but never see an inconsistent value, since such a list never exists. That solves the read-write race condition; we'd still want to keep the existing locking in add/removeHandler which prevents write-write race conditions. 

What do you think?
History
Date User Action Args
2019-06-20 14:03:34benspillersetrecipients: + benspiller, vinay.sajip
2019-06-20 14:03:34benspillersetmessageid: <1561039414.42.0.528306300619.issue35185@roundup.psfhosted.org>
2019-06-20 14:03:34benspillerlinkissue35185 messages
2019-06-20 14:03:33benspillercreate