[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2019-06-20 Thread Vinay Sajip
Vinay Sajip 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-b

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2019-06-20 Thread Ben Spiller
Ben Spiller added the comment: Interesting conversation. :) Yes I agree correctness is definitely top priority. :) I'd go further and say 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

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2019-06-20 Thread Vinay Sajip
Vinay Sajip 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 p

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2019-06-20 Thread Ben Spiller
Ben Spiller added the comment: 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 m

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2019-06-19 Thread Vinay Sajip
Vinay Sajip added the comment: The other alternative would be to lock around callHandlers(). With the change you propose to addHandler/removeHandler, there are no errors, but the output of your test program is (with the lock acquisition/release in place): Thread finished after 468 iterations

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2018-11-07 Thread Ned Deily
Change by Ned Deily : -- nosy: +vinay.sajip ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2018-11-07 Thread Ben Spiller
New submission from Ben Spiller : I just came across a fairly serious thread-safety / race condition bug in the logging.Loggers class, which causes random log lines to be lost i.e. not get passed to some of the registered handlers, if (other, unrelated) handlers are being added/removed using