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

> 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 :-)

----------

_______________________________________
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