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.17:28:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561051700.28.0.962021548423.issue35185@roundup.psfhosted.org>
In-reply-to
Content
> I'd prefer correctness to be always there automatically, rather than something the user must remember to enable by setting a flag such as lockCallHandling

Yes, I agree, I was just looking at different approaches while mulling all this over. Correctness-by-default can of course always be implemented by setting lockCallHandling to True by default, which is what I have currently in my benchmark testing.

Re. your change:

- self.handlers.remove(hdlr)
+ newhandlers = list(self.handlers)
+ newhandlers.remove(hdlr)
+ self.handlers = hdlr

Did you mean self.handlers = newhandlers in that last line? That's what I assumed you meant, but you've posted that twice now, so I'm not sure what you're getting at.

I agree that having a slower add/removeHandler is acceptable - certainly better than slowing down Logger.handle(). But I'm not sure about

> so without relying on any GIL locking callHandlers will still see the old list or the new list

on platforms other than CPython, since we can't be sure where thread pre-emption might happen (i.e. it could happen inside a source code line boundary) and locking at least has the benefit of having defined semantics.

The other issue is where someone might have subclassed and overridden add/removeHandler methods, for whatever reason. I know it's unlikely, but one never knows.

I think we're broadly on the same page. I'm just not yet sure what the best approach is :-)
History
Date User Action Args
2019-06-20 17:28:20vinay.sajipsetrecipients: + vinay.sajip, benspiller
2019-06-20 17:28:20vinay.sajipsetmessageid: <1561051700.28.0.962021548423.issue35185@roundup.psfhosted.org>
2019-06-20 17:28:20vinay.sajiplinkissue35185 messages
2019-06-20 17:28:19vinay.sajipcreate